diff options
author | Jens Axboe <jens.axboe@oracle.com> | 2007-01-23 10:30:17 -0500 |
---|---|---|
committer | Jens Axboe <jens.axboe@oracle.com> | 2007-07-16 02:52:45 -0400 |
commit | 264a0472183ce7ad05eea3360f5907880a1e5e78 (patch) | |
tree | ca66b08269fb08691059a4122e28ecfa3d90ef4f /block/bsg.c | |
parent | 5309cb38de65eddd5f7e125da750accf949f29e8 (diff) |
bsg: add cheasy error checks for sysfs stuff
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'block/bsg.c')
-rw-r--r-- | block/bsg.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/block/bsg.c b/block/bsg.c index c56618ae54c3..e97e3ec08ffc 100644 --- a/block/bsg.c +++ b/block/bsg.c | |||
@@ -983,10 +983,19 @@ int bsg_register_disk(struct gendisk *disk) | |||
983 | bsg_device_nr++; | 983 | bsg_device_nr++; |
984 | bcd->disk = disk; | 984 | bcd->disk = disk; |
985 | bcd->class_dev = class_device_create(bsg_class, NULL, dev, bcd->dev, "%s", disk->disk_name); | 985 | bcd->class_dev = class_device_create(bsg_class, NULL, dev, bcd->dev, "%s", disk->disk_name); |
986 | if (!bcd->class_dev) | ||
987 | goto err; | ||
986 | list_add_tail(&bcd->list, &bsg_class_list); | 988 | list_add_tail(&bcd->list, &bsg_class_list); |
987 | sysfs_create_link(&q->kobj, &bcd->class_dev->kobj, "bsg"); | 989 | if (sysfs_create_link(&q->kobj, &bcd->class_dev->kobj, "bsg")) |
990 | goto err; | ||
988 | mutex_unlock(&bsg_mutex); | 991 | mutex_unlock(&bsg_mutex); |
989 | return 0; | 992 | return 0; |
993 | err: | ||
994 | bsg_device_nr--; | ||
995 | if (bcd->class_dev) | ||
996 | class_device_destroy(bsg_class, MKDEV(BSG_MAJOR, bcd->minor)); | ||
997 | mutex_unlock(&bsg_mutex); | ||
998 | return -ENOMEM; | ||
990 | } | 999 | } |
991 | 1000 | ||
992 | static int __init bsg_init(void) | 1001 | static int __init bsg_init(void) |