Skip to content

Commit 4ce7ada

Browse files
biger410martinkpetersen
authored andcommitted
scsi: core: Fix error handling for scsi_alloc_sdev()
After scsi_sysfs_device_initialize() was called, error paths must call __scsi_remove_device(). Fixes: 1ac22c8 ("scsi: core: Fix refcount leak for tagset_refcnt") Cc: stable@vger.kernel.org Signed-off-by: Junxiao Bi <junxiao.bi@oracle.com> Reviewed-by: John Garry <john.g.garry@oracle.com> Reviewed-by: Bart Van Assche <bvanassche@acm.org> Link: https://patch.msgid.link/20260304164603.51528-1-junxiao.bi@oracle.com Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 14d4ac1 commit 4ce7ada

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

drivers/scsi/scsi_scan.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -360,12 +360,8 @@ static struct scsi_device *scsi_alloc_sdev(struct scsi_target *starget,
360360
* default device queue depth to figure out sbitmap shift
361361
* since we use this queue depth most of times.
362362
*/
363-
if (scsi_realloc_sdev_budget_map(sdev, depth)) {
364-
kref_put(&sdev->host->tagset_refcnt, scsi_mq_free_tags);
365-
put_device(&starget->dev);
366-
kfree(sdev);
367-
goto out;
368-
}
363+
if (scsi_realloc_sdev_budget_map(sdev, depth))
364+
goto out_device_destroy;
369365

370366
scsi_change_queue_depth(sdev, depth);
371367

0 commit comments

Comments
 (0)