stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Li Bin <huawei.libin@huawei.com>,
	Douglas Gilbert <dgilbert@interlog.com>,
	"Martin K . Petersen" <martin.petersen@oracle.com>,
	Sasha Levin <sashal@kernel.org>,
	linux-scsi@vger.kernel.org
Subject: [PATCH AUTOSEL 4.4 4/8] scsi: sg: add sg_remove_request in sg_common_write
Date: Fri, 24 Apr 2020 08:24:59 -0400	[thread overview]
Message-ID: <20200424122503.11046-4-sashal@kernel.org> (raw)
In-Reply-To: <20200424122503.11046-1-sashal@kernel.org>

From: Li Bin <huawei.libin@huawei.com>

[ Upstream commit 849f8583e955dbe3a1806e03ecacd5e71cce0a08 ]

If the dxfer_len is greater than 256M then the request is invalid and we
need to call sg_remove_request in sg_common_write.

Link: https://lore.kernel.org/r/1586777361-17339-1-git-send-email-huawei.libin@huawei.com
Fixes: f930c7043663 ("scsi: sg: only check for dxfer_len greater than 256M")
Acked-by: Douglas Gilbert <dgilbert@interlog.com>
Signed-off-by: Li Bin <huawei.libin@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/scsi/sg.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index e1639e80db536..63e21ca538f19 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -820,8 +820,10 @@ sg_common_write(Sg_fd * sfp, Sg_request * srp,
 			"sg_common_write:  scsi opcode=0x%02x, cmd_size=%d\n",
 			(int) cmnd[0], (int) hp->cmd_len));
 
-	if (hp->dxfer_len >= SZ_256M)
+	if (hp->dxfer_len >= SZ_256M) {
+		sg_remove_request(sfp, srp);
 		return -EINVAL;
+	}
 
 	k = sg_start_req(srp, cmnd);
 	if (k) {
-- 
2.20.1


  parent reply	other threads:[~2020-04-24 12:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-24 12:24 [PATCH AUTOSEL 4.4 1/8] ALSA: hda: Don't release card at firmware loading error Sasha Levin
2020-04-24 12:24 ` [PATCH AUTOSEL 4.4 2/8] ALSA: hda: Keep the controller initialization even if no codecs found Sasha Levin
2020-04-24 12:24 ` [PATCH AUTOSEL 4.4 3/8] scsi: target: fix PR IN / READ FULL STATUS for FC Sasha Levin
2020-04-24 12:24 ` Sasha Levin [this message]
2020-04-24 12:25 ` [PATCH AUTOSEL 4.4 5/8] xen/xenbus: ensure xenbus_map_ring_valloc() returns proper grant status Sasha Levin
2020-04-24 12:25 ` [PATCH AUTOSEL 4.4 6/8] net/cxgb4: Check the return from t4_query_params properly Sasha Levin
2020-04-24 12:25 ` [PATCH AUTOSEL 4.4 7/8] ext4: convert BUG_ON's to WARN_ON's in mballoc.c Sasha Levin
2020-04-24 12:25 ` [PATCH AUTOSEL 4.4 8/8] of: unittest: kmemleak on changeset destroy Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200424122503.11046-4-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=dgilbert@interlog.com \
    --cc=huawei.libin@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).