[SCSI] bsg: fix bsg_register_queue error path
authorJames Bottomley <James.Bottomley@steeleye.com>
Fri, 20 Jul 2007 21:50:10 +0000 (16:50 -0500)
committerJames Bottomley <jejb@mulgrave.localdomain>
Sat, 21 Jul 2007 13:53:33 +0000 (08:53 -0500)
unfortunately, if IS_ERR(class_dev) is true, that means class_dev isn't
null and the check in the error leg is pointless ... it's also asking
for trouble to request unregistration of a device we haven't actually
created (although it works currently).  Fix by using explicit gotos and
unregisters.

Acked-by: FUJITA Tomonori <tomof@acm.org>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
block/bsg.c

index 4e0be1b2e2a084812ba731f21f068c289502307e..0e3d5d490d208411755a6df7b0b0dbf90b4c08cc 100644 (file)
@@ -993,7 +993,7 @@ retry:
        if (q->kobj.sd) {
                ret = sysfs_create_link(&q->kobj, &bcd->class_dev->kobj, "bsg");
                if (ret)
-                       goto err;
+                       goto err_unregister;
        }
 
        list_add_tail(&bcd->list, &bsg_class_list);
@@ -1001,9 +1001,10 @@ retry:
 
        mutex_unlock(&bsg_mutex);
        return 0;
+
+err_unregister:
+       class_device_unregister(class_dev);
 err:
-       if (class_dev)
-               class_device_destroy(bsg_class, MKDEV(bsg_major, bcd->minor));
        mutex_unlock(&bsg_mutex);
        return ret;
 }