[PATCH] scsi: Fix sg memory leak building 2 scatter-gather lists

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,
    There is a memory leak in sg that is hit in the case when direct_io is in 
use and the length of the data is longer than we can fit into a single 
scatter-gather list.  Two scatter-gather lists are allocated for each io that 
meets the criteria, and only 1 ever gets released.

    The following fix releases the scatter-gather list created by the 
attempted sg_build_direct when abandoning the effort in favor of 
sg_build_indirect.  sg_build_indirect creates a new scatter-gather list.


Signed-off-by: Bryan Holty <lgeek@xxxxxxxxxxxxxxx>

--- a/drivers/scsi/sg.c	2006-03-03 13:17:23.000000000 -0600
+++ b/drivers/scsi/sg.c	2006-03-22 16:32:17.536091840 -0600
@@ -1648,6 +1648,7 @@
 		res = sg_build_direct(srp, sfp, dxfer_len);
 		if (res <= 0)	/* -ve -> error, 0 -> done, 1 -> try indirect */
 			return res;
+		sg_remove_scat(req_schp);
 	}
 	if ((!sg_res_in_use(sfp)) && (dxfer_len <= rsv_schp->bufflen))
 		sg_link_reserve(sfp, srp, dxfer_len);
-- 
--
 Bryan Holty
-
: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux