diff options
| author | James Bottomley <James.Bottomley@steeleye.com> | 2007-07-20 17:50:10 -0400 |
|---|---|---|
| committer | James Bottomley <jejb@mulgrave.localdomain> | 2007-07-21 09:53:33 -0400 |
| commit | 6826ee4fdbe24c7aab56ce833ef94be81d190587 (patch) | |
| tree | 4e14f18eec72bf421fde21abb3113880fe37c428 | |
| parent | d73f5222a618a91452d41c29f5996ce3d9c63673 (diff) | |
[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>
| -rw-r--r-- | block/bsg.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/block/bsg.c b/block/bsg.c index 4e0be1b2e2a0..0e3d5d490d20 100644 --- a/block/bsg.c +++ b/block/bsg.c | |||
| @@ -993,7 +993,7 @@ retry: | |||
| 993 | if (q->kobj.sd) { | 993 | if (q->kobj.sd) { |
| 994 | ret = sysfs_create_link(&q->kobj, &bcd->class_dev->kobj, "bsg"); | 994 | ret = sysfs_create_link(&q->kobj, &bcd->class_dev->kobj, "bsg"); |
| 995 | if (ret) | 995 | if (ret) |
| 996 | goto err; | 996 | goto err_unregister; |
| 997 | } | 997 | } |
| 998 | 998 | ||
| 999 | list_add_tail(&bcd->list, &bsg_class_list); | 999 | list_add_tail(&bcd->list, &bsg_class_list); |
| @@ -1001,9 +1001,10 @@ retry: | |||
| 1001 | 1001 | ||
| 1002 | mutex_unlock(&bsg_mutex); | 1002 | mutex_unlock(&bsg_mutex); |
| 1003 | return 0; | 1003 | return 0; |
| 1004 | |||
| 1005 | err_unregister: | ||
| 1006 | class_device_unregister(class_dev); | ||
| 1004 | err: | 1007 | err: |
| 1005 | if (class_dev) | ||
| 1006 | class_device_destroy(bsg_class, MKDEV(bsg_major, bcd->minor)); | ||
| 1007 | mutex_unlock(&bsg_mutex); | 1008 | mutex_unlock(&bsg_mutex); |
| 1008 | return ret; | 1009 | return ret; |
| 1009 | } | 1010 | } |
