aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaesoo Lee <jalee@purestorage.com>2019-04-09 17:02:22 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-04-27 09:36:36 +0200
commit1aa2682d0a98bb025f8dd29df11f978a249a81ba (patch)
tree5d7fb29f554f8448a0d32f1cb83415bdeb0828c3
parent8f2ef0e8f9670f83b3fe7e620eb7ae98910ff627 (diff)
downloadlinux-yocto-1aa2682d0a98bb025f8dd29df11f978a249a81ba.tar.gz
linux-yocto-1aa2682d0a98bb025f8dd29df11f978a249a81ba.tar.bz2
linux-yocto-1aa2682d0a98bb025f8dd29df11f978a249a81ba.zip
scsi: core: set result when the command cannot be dispatched
commit be549d49115422f846b6d96ee8fd7173a5f7ceb0 upstream. When SCSI blk-mq is enabled, there is a bug in handling errors in scsi_queue_rq. Specifically, the bug is not setting result field of scsi_request correctly when the dispatch of the command has been failed. Since the upper layer code including the sg_io ioctl expects to receive any error status from result field of scsi_request, the error is silently ignored and this could cause data corruptions for some applications. Fixes: d285203cf647 ("scsi: add support for a blk-mq based I/O path.") Cc: <stable@vger.kernel.org> Signed-off-by: Jaesoo Lee <jalee@purestorage.com> Reviewed-by: Hannes Reinecke <hare@suse.com> Reviewed-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/scsi/scsi_lib.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 655790f30434..1fc832751a4f 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -2149,8 +2149,12 @@ out_put_budget:
ret = BLK_STS_DEV_RESOURCE;
break;
default:
+ if (unlikely(!scsi_device_online(sdev)))
+ scsi_req(req)->result = DID_NO_CONNECT << 16;
+ else
+ scsi_req(req)->result = DID_ERROR << 16;
/*
- * Make sure to release all allocated ressources when
+ * Make sure to release all allocated resources when
* we hit an error, as we will never see this command
* again.
*/