]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/5.0.10/scsi-core-set-result-when-the-command-cannot-be-dispatched.patch
move 5.10 queue back in place
[thirdparty/kernel/stable-queue.git] / releases / 5.0.10 / scsi-core-set-result-when-the-command-cannot-be-dispatched.patch
CommitLineData
9d0aa67b
GKH
1From be549d49115422f846b6d96ee8fd7173a5f7ceb0 Mon Sep 17 00:00:00 2001
2From: Jaesoo Lee <jalee@purestorage.com>
3Date: Tue, 9 Apr 2019 17:02:22 -0700
4Subject: scsi: core: set result when the command cannot be dispatched
5
6From: Jaesoo Lee <jalee@purestorage.com>
7
8commit be549d49115422f846b6d96ee8fd7173a5f7ceb0 upstream.
9
10When SCSI blk-mq is enabled, there is a bug in handling errors in
11scsi_queue_rq. Specifically, the bug is not setting result field of
12scsi_request correctly when the dispatch of the command has been
13failed. Since the upper layer code including the sg_io ioctl expects to
14receive any error status from result field of scsi_request, the error is
15silently ignored and this could cause data corruptions for some
16applications.
17
18Fixes: d285203cf647 ("scsi: add support for a blk-mq based I/O path.")
19Cc: <stable@vger.kernel.org>
20Signed-off-by: Jaesoo Lee <jalee@purestorage.com>
21Reviewed-by: Hannes Reinecke <hare@suse.com>
22Reviewed-by: Bart Van Assche <bvanassche@acm.org>
23Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
24Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
25
26---
27 drivers/scsi/scsi_lib.c | 6 +++++-
28 1 file changed, 5 insertions(+), 1 deletion(-)
29
30--- a/drivers/scsi/scsi_lib.c
31+++ b/drivers/scsi/scsi_lib.c
32@@ -1763,8 +1763,12 @@ out_put_budget:
33 ret = BLK_STS_DEV_RESOURCE;
34 break;
35 default:
36+ if (unlikely(!scsi_device_online(sdev)))
37+ scsi_req(req)->result = DID_NO_CONNECT << 16;
38+ else
39+ scsi_req(req)->result = DID_ERROR << 16;
40 /*
41- * Make sure to release all allocated ressources when
42+ * Make sure to release all allocated resources when
43 * we hit an error, as we will never see this command
44 * again.
45 */