scsi: core: fix error handling for scsi_alloc_sdev()
PATCH 1/1 scsi: core: fix error handling for scsi_alloc_sdev()
scsi_sysfs_device_initialize() was already invoked when scsi_realloc_sdev_budget_map() fail, it will need invoke __scsi_remove_device() to do the error handling.
Fixes 1ac22c8eae81 ("scsi: core: Fix refcount leak for tagset_refcnt")
Signed-off-by Junxiao Bi <[email protected]>
--- drivers/scsi/scsi_scan.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/scsi/scsi_scan.c +2 -6
@@ -360,12 +360,8 @@ static struct scsi_device *scsi_alloc_sdev(struct scsi_target *starget,* default device queue depth to figure out sbitmap shift * since we use this queue depth most of times. */ -if (scsi_realloc_sdev_budget_map (sdev, depth)) { -kref_put (&sdev->host->tagset_refcnt, scsi_mq_free_tags); -put_device (&starget->dev); -kfree (sdev); - goto out; - } +if (scsi_realloc_sdev_budget_map (sdev, depth)) + goto out_device_destroy;scsi_change_queue_depth (sdev, depth);
Signature · 1 line
2.50.1 (Apple Git-155)
Quoted 3 lines · Junxiao Bi
scsi_sysfs_device_initialize()was already invoked whenscsi_realloc_sdev_budget_map()fail, it will need invoke__scsi_remove_device()to do the error handling.
That's too vague. The description should mention that after scsi_sysfs_device_initialize() has been called, error paths must call __scsi_remove_device().
Otherwise this patch looks good to me.
Thanks,
Bart.