Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp848894yba; Wed, 24 Apr 2019 10:34:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqxbtx1ofeYvwfrmj/WFuAyKLgCKbj2sDi0QG9H37wVHbERivnE3a2R/EMWCR4XlfP5icaNu X-Received: by 2002:a63:6194:: with SMTP id v142mr13815171pgb.411.1556127277167; Wed, 24 Apr 2019 10:34:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556127277; cv=none; d=google.com; s=arc-20160816; b=SZzJr/8E/ypkAc/4vK80WS5kXHtvWBy28iWbA07gSHp7xRf7+ndpTas8wRF9crCI+J NfDPCspMoe6FIEY7XNdhhIwEoafulkrUrzx7FxO9ITlQqhsBbdUNfo8yavz3HbBwV0at NSmZbKmIn2d6lxkQTyGGqJ0eVi12msQp6s71kK92uYTCECBONUkw1U4J6sEphcmRP2K9 R3dLKsoDnymsiQEkzu7CUbo1ECP1898DbhZFCezj83t7Sqa1MqZqai9sAaQoQtMl0sX5 rEQgowq8sG9NwNDuRsmDQ8Evpct8+wrPo1xWY9zMUoAcKsoYcom6+z9jkZf4hIM26BWw GmvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=6B/voJj1nie7SJax9hq8mMJdF7WQflbE3QOmo2omI4U=; b=JN/CBipGcql5tD5v4JdzGsmVcFQUkGktelS+qi6VLFsJ0gCLpV04p+Vcw/ON2LP2yg 5492CSLKSZ9J0unT1nw5+VQGuwqXb6rfeM1CqXcKe1ev+jc/vtk2KUh4jRWpuQkW4zBW PUNLp9dYA4pi2pJBtWsF7Ot6hADWu3RsIGqYW3tXXa+c0EM0h6OQkmVIi6nrtWt/F3Rj Mwowf5pXKn699flyo3kGk1Ghgt/jhBfq2Rrt1i27DVFls8kQEaZJZ3UVO+WDSdohEMqX WcXXgw1oQtWPlmZ0bTHKYYUbBAq2LbovkdOcB16pOXrMzLQPic+27bX5iVWacyoelLd0 uCHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=H+4yOzEn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a190si18448276pge.88.2019.04.24.10.34.21; Wed, 24 Apr 2019 10:34:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=H+4yOzEn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403823AbfDXRbb (ORCPT + 99 others); Wed, 24 Apr 2019 13:31:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:57992 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403800AbfDXRb3 (ORCPT ); Wed, 24 Apr 2019 13:31:29 -0400 Received: from localhost (62-193-50-229.as16211.net [62.193.50.229]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2826B2054F; Wed, 24 Apr 2019 17:31:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556127088; bh=I9HwzjyGsE046FN12eL1NHu1z2i+9Cxh31PFHcPtGTM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H+4yOzEnOGU/a/thq8a10Rs8pXzZHvJk+LYzpnd+wBLSQGlIatdUDKhjFidGjvdmm lepJSoEqNLS38wFb6frz4RiRQ6j4S3Sgg9/MbKj4A2F25RJPnrPwHOf9mFhS5toCNa GnpB5bSQVrCMIU6zpcs3DGM5T9KXp3BKMkpfluEM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jaesoo Lee , Hannes Reinecke , Bart Van Assche , "Martin K. Petersen" Subject: [PATCH 4.19 58/96] scsi: core: set result when the command cannot be dispatched Date: Wed, 24 Apr 2019 19:10:03 +0200 Message-Id: <20190424170923.663054867@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190424170919.829037226@linuxfoundation.org> References: <20190424170919.829037226@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jaesoo Lee 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: Signed-off-by: Jaesoo Lee Reviewed-by: Hannes Reinecke Reviewed-by: Bart Van Assche Signed-off-by: Martin K. Petersen Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/scsi_lib.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- 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. */