Skip to contentSkip to conversation

fix sg leak when scsi_execute_async fails

PATCH In review Mike Christie 2 participants 2 messages Mar 22, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix sg leak when scsi_execute_async fails

Doug found a bug where if scsi_execute_async fails, we are leaking sg resources. scsi_do_req never failed so we did not have to handle that case before.

Patch was made against scsi-misc. Not sure if this should also go to stable?

drivers/scsi/sg.c +1 -0
index a8b05ce..71994ea 100644
@@ -748,6 +748,7 @@ sg_common_write(Sg_fd * sfp, Sg_request 
 		/*
 		 * most likely out of mem, but could also be a bad map
 		 */
+		sg_finish_rem_req(srp);
 		return -ENOMEM;
 	} else
 		return 0;
#1 lore raw
Quoted 3 lines · Mike Christie

Doug found a bug where if scsi_execute_async fails, we are leaking sg resources. scsi_do_req never failed so we did not have to handle that case before.

When a SCSI command request falls foul of the extra requirements in lk 2.6.16 (e.g. max_sectors), the resulting ENOMEM leaves unfinished business in the sg driver's own data structures. This can be seen with 'cat /proc/scs/sg/debug' .

Quoted 2 lines

Patch was made against scsi-misc. Not sure if this should also go to stable?

I think it should. It fixes a bug on an error path by adding the same cleanup call as found on other paths.

Quoted 1 line

Doug Gilbert

Quoted 14 lines
drivers/scsi/sg.c +1 -0
index a8b05ce..71994ea 100644
@@ -748,6 +748,7 @@ sg_common_write(Sg_fd * sfp, Sg_request 
 		/*
 		 * most likely out of mem, but could also be a bad map
 		 */
+		sg_finish_rem_req(srp);
 		return -ENOMEM;
 	} else
 		return 0;