Skip to content

Commit

Permalink
scsi: sg: add sg_remove_request in sg_common_write
Browse files Browse the repository at this point in the history
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: f930c70 ("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>
  • Loading branch information
Li Bin authored and Martin K. Petersen committed Apr 14, 2020
1 parent 066f79a commit 849f858
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/scsi/sg.c
Original file line number Diff line number Diff line change
Expand Up @@ -793,8 +793,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) {
Expand Down

0 comments on commit 849f858

Please sign in to comment.