Skip to contentSkip to conversation

scsi: sg: add sg_remove_request in sg_common_write

PATCH Applied Li Bin 3 participants 3 messages Apr 13, 2020 – Apr 14, 2020

Subsystems (2)
lore
Share & tools
lore

Li Bin

author
#0 lore raw

PATCH 1/1 scsi: sg: add sg_remove_request in sg_common_write

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")
---
 drivers/scsi/sg.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/scsi/sg.c +3 -1
index 4e6af592..9c0ee19 100644
@@ -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) {
Signature · 1 line
1.7.12.4
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 1 line · Li Bin

If the dxfer_len is greater than 256M that the request is invalid,

s/that/then/

Quoted 3 lines

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".

Quoted 22 lines
---
  drivers/scsi/sg.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/scsi/sg.c +3 -1
index 4e6af592..9c0ee19 100644
@@ -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) {
#2 lore raw
In reply to Li Bin

Li,

Quoted 2 lines

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!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering