diff options
author | Ye Bin <yebin10@huawei.com> | 2020-05-18 15:44:20 +0800 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2020-05-19 21:54:17 -0400 |
commit | 4dea170f4fb225984b4f2f1cf0a41d485177b905 (patch) | |
tree | 56b5b4f84c3438fc546318c2ccf8931378ca0611 /drivers/scsi/scsi_error.c | |
parent | 7ffa5b939751b6638e4a99518775c8503fbb46be (diff) | |
download | lwn-4dea170f4fb225984b4f2f1cf0a41d485177b905.tar.gz lwn-4dea170f4fb225984b4f2f1cf0a41d485177b905.zip |
scsi: core: Fix incorrect usage of shost_for_each_device
shost_for_each_device(sdev, shost) \
for ((sdev) = __scsi_iterate_devices((shost), NULL); \
(sdev); \
(sdev) = __scsi_iterate_devices((shost), (sdev)))
When terminating shost_for_each_device() iteration with break or return,
scsi_device_put() should be used to prevent stale scsi device references
from being left behind.
Link: https://lore.kernel.org/r/20200518074420.39275-1-yebin10@huawei.com
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Ye Bin <yebin10@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/scsi/scsi_error.c')
-rw-r--r-- | drivers/scsi/scsi_error.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index 978be1602f71..927b1e641842 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -1412,6 +1412,7 @@ static int scsi_eh_stu(struct Scsi_Host *shost, sdev_printk(KERN_INFO, sdev, "%s: skip START_UNIT, past eh deadline\n", current->comm)); + scsi_device_put(sdev); break; } stu_scmd = NULL; @@ -1478,6 +1479,7 @@ static int scsi_eh_bus_device_reset(struct Scsi_Host *shost, sdev_printk(KERN_INFO, sdev, "%s: skip BDR, past eh deadline\n", current->comm)); + scsi_device_put(sdev); break; } bdr_scmd = NULL; |