From patchwork Fri Jun 19 14:31:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "gregkh@linuxfoundation.org" X-Patchwork-Id: 223624 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48EB8C433DF for ; Fri, 19 Jun 2020 16:54:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1B48D20786 for ; Fri, 19 Jun 2020 16:54:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592585680; bh=dALp7G7shgyUB24rZx0WuQCo/bX2/oiiwiY0sh1cs0A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=nefYy539QsUSA2u3875fkb9dTWxriRyJ09gUoIwW9KJcPxN+BKWxpE3nKPUpBBIPt zwMfRv8IeoziKruw9nLBxFJ87zQRp0FfH6suJt80DmZgV/RQTWPoS4ghe1fHF84RXR ghfgXJoovTZj+RawHcNkeeyLHvcvyd6KFJ8nKkbI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733262AbgFSQyi (ORCPT ); Fri, 19 Jun 2020 12:54:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:52932 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387534AbgFSOg3 (ORCPT ); Fri, 19 Jun 2020 10:36:29 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 791A02070A; Fri, 19 Jun 2020 14:36:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592577388; bh=dALp7G7shgyUB24rZx0WuQCo/bX2/oiiwiY0sh1cs0A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xzHbbD7mvrjOJOVYdKx6UBImLWDcLkSS+3fGqXINCw4AQz7VJx/QKrgW9euPPsh/b O01gh7Zyvo2ALrjvmfhWeNDrVnm+9CTMZjteYevRtcOREaTzCuuVZTizD3Jhs7g5Kt CKII2m3tOnh3U6qz1/LVXNyrEzr3jrzGIp/AkqC4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johannes Thumshirn , Christoph Hellwig , Hannes Reinecke , Bart Van Assche , "Martin K. Petersen" , Nobuhiro Iwamatsu Subject: [PATCH 4.4 003/101] scsi: return correct blkprep status code in case scsi_init_io() fails. Date: Fri, 19 Jun 2020 16:31:52 +0200 Message-Id: <20200619141614.191595911@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619141614.001544111@linuxfoundation.org> References: <20200619141614.001544111@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Johannes Thumshirn commit e7661a8e5ce10b5321882d0bbaf3f81070903319 upstream. When instrumenting the SCSI layer to run into the !blk_rq_nr_phys_segments(rq) case the following warning emitted from the block layer: blk_peek_request: bad return=-22 This happens because since commit fd3fc0b4d730 ("scsi: don't BUG_ON() empty DMA transfers") we return the wrong error value from scsi_prep_fn() back to the block layer. [mkp: silenced checkpatch] Signed-off-by: Johannes Thumshirn Fixes: fd3fc0b4d730 scsi: don't BUG_ON() empty DMA transfers Cc: Reviewed-by: Christoph Hellwig Reviewed-by: Hannes Reinecke Reviewed-by: Bart Van Assche Signed-off-by: Martin K. Petersen [iwamatsu: - backport for 4.4.y and 4.9.y - Use rq->nr_phys_segments instead of blk_rq_nr_phys_segments] Signed-off-by: Nobuhiro Iwamatsu Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/scsi_lib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1118,10 +1118,10 @@ int scsi_init_io(struct scsi_cmnd *cmd) struct scsi_device *sdev = cmd->device; struct request *rq = cmd->request; bool is_mq = (rq->mq_ctx != NULL); - int error; + int error = BLKPREP_KILL; if (WARN_ON_ONCE(!rq->nr_phys_segments)) - return -EINVAL; + goto err_exit; error = scsi_init_sgtable(rq, &cmd->sdb); if (error)