]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
bsg: add cheasy error checks for sysfs stuff
authorJens Axboe <jens.axboe@oracle.com>
Tue, 23 Jan 2007 15:30:17 +0000 (16:30 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Mon, 16 Jul 2007 06:52:45 +0000 (08:52 +0200)
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
block/bsg.c

index c56618ae54c326651e237b9984b73e06095c62b6..e97e3ec08ffc482c0a785c092258b90151685c6a 100644 (file)
@@ -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)