Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 49c67980 authored by Jaesoo Lee's avatar Jaesoo Lee Committed by Greg Kroah-Hartman
Browse files

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: d285203c ("scsi: add support for a blk-mq based I/O path.")
Cc: <stable@vger.kernel.org>
Signed-off-by: default avatarJaesoo Lee <jalee@purestorage.com>
Reviewed-by: default avatarHannes Reinecke <hare@suse.com>
Reviewed-by: default avatarBart Van Assche <bvanassche@acm.org>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent d11a33e9
Loading
Loading
Loading
Loading
+5 −1
Original line number Original line Diff line number Diff line
@@ -2050,8 +2050,12 @@ static blk_status_t scsi_queue_rq(struct blk_mq_hw_ctx *hctx,
			blk_mq_delay_run_hw_queue(hctx, SCSI_QUEUE_DELAY);
			blk_mq_delay_run_hw_queue(hctx, SCSI_QUEUE_DELAY);
		break;
		break;
	default:
	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
		 * we hit an error, as we will never see this command
		 * again.
		 * again.
		 */
		 */