]> www.infradead.org Git - users/dwmw2/linux.git/commit
scsi: core: Fix incorrect usage of shost_for_each_device
authorYe Bin <yebin10@huawei.com>
Mon, 18 May 2020 07:44:20 +0000 (15:44 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 24 Jun 2020 15:48:51 +0000 (17:48 +0200)
commit74c5fd5dedde91e58acc52eb5948788496a017a2
tree9690ea0848ef73db178a6df9d3d73284fa78ebb3
parent07a98d17eb1dd896de475c1a74121c3b3e301ea3
scsi: core: Fix incorrect usage of shost_for_each_device

[ Upstream commit 4dea170f4fb225984b4f2f1cf0a41d485177b905 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/scsi/scsi_error.c
drivers/scsi/scsi_lib.c