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

Commit 45533ebd authored by Li Bin's avatar Li Bin Committed by Greg Kroah-Hartman
Browse files

scsi: sg: add sg_remove_request in sg_common_write

commit 849f8583e955dbe3a1806e03ecacd5e71cce0a08 upstream.

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: f930c704 ("scsi: sg: only check for dxfer_len greater than 256M")
Acked-by: default avatarDouglas Gilbert <dgilbert@interlog.com>
Signed-off-by: default avatarLi Bin <huawei.libin@huawei.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 2b91a236
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -808,8 +808,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) {