diff mbox series

scsi: sg: add sg_remove_request in sg_common_write

Message ID 1586777361-17339-1-git-send-email-huawei.libin@huawei.com (mailing list archive)
State Mainlined
Commit 849f8583e955dbe3a1806e03ecacd5e71cce0a08
Headers show
Series scsi: sg: add sg_remove_request in sg_common_write | expand

Commit Message

Li Bin April 13, 2020, 11:29 a.m. UTC
If the dxfer_len is greater than 256M that the request is invalid,
it should call sg_remove_request in sg_common_write.

Fixes: f930c7043663 ("scsi: sg: only check for dxfer_len greater than 256M")
Signed-off-by: Li Bin <huawei.libin@huawei.com>
---
 drivers/scsi/sg.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Douglas Gilbert April 14, 2020, 1:17 a.m. UTC | #1
On 2020-04-13 7:29 a.m., Li Bin wrote:
> If the dxfer_len is greater than 256M that the request is invalid,
s/that/then/
> it should call sg_remove_request in sg_common_write.
> 
> Fixes: f930c7043663 ("scsi: sg: only check for dxfer_len greater than 256M")

Code fix is fine, please replace the "that" in the first comment line
above with "then".

Acked-by: Douglas Gilbert <dgilbert@interlog.com>

> Signed-off-by: Li Bin <huawei.libin@huawei.com>
> ---
>   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 4e6af592..9c0ee19 100644
> --- a/drivers/scsi/sg.c
> +++ b/drivers/scsi/sg.c
> @@ -793,8 +793,10 @@ static int get_sg_io_pack_id(int *pack_id, void __user *buf, size_t count)
>   			"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) {
>
Martin K. Petersen April 14, 2020, 1:59 a.m. UTC | #2
Li,

> If the dxfer_len is greater than 256M that the request is invalid,
> it should call sg_remove_request in sg_common_write.

Applied to 5.7/scsi-fixes with a tweak to the commit description. Thanks!
diff mbox series

Patch

diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 4e6af592..9c0ee19 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -793,8 +793,10 @@  static int get_sg_io_pack_id(int *pack_id, void __user *buf, size_t count)
 			"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) {