In commit 4dea170f4fb2 ("scsi: core: Fix incorrect usage of shost_for_each_device") fix usage of shost_for_each_device in function scsi_host_block. Fix: 2bb955840c1d("scsi: core: add scsi_host_(block,unblock) helper function") Signed-off-by: Ye Bin <yebin10@xxxxxxxxxx> --- drivers/scsi/scsi_lib.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index f3bf2648105c..65fde27b8b08 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -2811,8 +2811,10 @@ scsi_host_block(struct Scsi_Host *shost) mutex_lock(&sdev->state_mutex); ret = scsi_internal_device_block_nowait(sdev); mutex_unlock(&sdev->state_mutex); - if (ret) + if (ret) { + scsi_device_put(sdev); break; + } } /* -- 2.25.4