summaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorJens Axboe <jens.axboe@oracle.com>2007-01-23 16:30:17 +0100
committerJens Axboe <jens.axboe@oracle.com>2007-07-16 08:52:45 +0200
commit264a0472183ce7ad05eea3360f5907880a1e5e78 (patch)
treeca66b08269fb08691059a4122e28ecfa3d90ef4f /block
parent5309cb38de65eddd5f7e125da750accf949f29e8 (diff)
bsg: add cheasy error checks for sysfs stuff
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'block')
-rw-r--r--block/bsg.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/block/bsg.c b/block/bsg.c
index c56618ae54c..e97e3ec08ff 100644
--- a/block/bsg.c
+++ b/block/bsg.c
@@ -983,10 +983,19 @@ int bsg_register_disk(struct gendisk *disk)
bsg_device_nr++;
bcd->disk = disk;
bcd->class_dev = class_device_create(bsg_class, NULL, dev, bcd->dev, "%s", disk->disk_name);
+ if (!bcd->class_dev)
+ goto err;
list_add_tail(&bcd->list, &bsg_class_list);
- sysfs_create_link(&q->kobj, &bcd->class_dev->kobj, "bsg");
+ if (sysfs_create_link(&q->kobj, &bcd->class_dev->kobj, "bsg"))
+ goto err;
mutex_unlock(&bsg_mutex);
return 0;
+err:
+ bsg_device_nr--;
+ if (bcd->class_dev)
+ class_device_destroy(bsg_class, MKDEV(BSG_MAJOR, bcd->minor));
+ mutex_unlock(&bsg_mutex);
+ return -ENOMEM;
}
static int __init bsg_init(void)