[SCSI] bsg: fix bsg_register_queue error path

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>

authored by James Bottomley and committed by James Bottomley 6826ee4f d73f5222

+4 -3
+4 -3
block/bsg.c
··· 993 if (q->kobj.sd) { 994 ret = sysfs_create_link(&q->kobj, &bcd->class_dev->kobj, "bsg"); 995 if (ret) 996 - goto err; 997 } 998 999 list_add_tail(&bcd->list, &bsg_class_list); ··· 1001 1002 mutex_unlock(&bsg_mutex); 1003 return 0; 1004 err: 1005 - if (class_dev) 1006 - class_device_destroy(bsg_class, MKDEV(bsg_major, bcd->minor)); 1007 mutex_unlock(&bsg_mutex); 1008 return ret; 1009 }
··· 993 if (q->kobj.sd) { 994 ret = sysfs_create_link(&q->kobj, &bcd->class_dev->kobj, "bsg"); 995 if (ret) 996 + goto err_unregister; 997 } 998 999 list_add_tail(&bcd->list, &bsg_class_list); ··· 1001 1002 mutex_unlock(&bsg_mutex); 1003 return 0; 1004 + 1005 + err_unregister: 1006 + class_device_unregister(class_dev); 1007 err: 1008 mutex_unlock(&bsg_mutex); 1009 return ret; 1010 }