Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: sg: add sg_remove_request in sg_common_write

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>

authored by

Li Bin and committed by
Martin K. Petersen
849f8583 066f79a5

+3 -1
+3 -1
drivers/scsi/sg.c
··· 793 793 "sg_common_write: scsi opcode=0x%02x, cmd_size=%d\n", 794 794 (int) cmnd[0], (int) hp->cmd_len)); 795 795 796 - if (hp->dxfer_len >= SZ_256M) 796 + if (hp->dxfer_len >= SZ_256M) { 797 + sg_remove_request(sfp, srp); 797 798 return -EINVAL; 799 + } 798 800 799 801 k = sg_start_req(srp, cmnd); 800 802 if (k) {