Skip to content

Commit

Permalink
[SCSI] bsg: fix bsg_register_queue error path
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: James Bottomley <[email protected]>
  • Loading branch information
James Bottomley authored and James Bottomley committed Jul 21, 2007
1 parent d73f522 commit 6826ee4
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions block/bsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -993,17 +993,18 @@ int bsg_register_queue(struct request_queue *q, const char *name)
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);
bsg_device_nr++;

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;
}
Expand Down

0 comments on commit 6826ee4

Please sign in to comment.