When error encountered, the allocated page/s could be returned back to the mm system of linus, which triggers mem leak. Signed-off-by: Hillf Danton <dhillf@xxxxxxxxx> --- --- a/drivers/scsi/scsi_tgt_if.c 2010-09-13 07:07:38.000000000 +0800 +++ b/drivers/scsi/scsi_tgt_if.c 2010-11-09 21:35:10.000000000 +0800 @@ -18,6 +18,10 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA + * + * Nov 9, 2010 Hillf Danton <dhillf@xxxxxxxxx> + * minor fix of memory leakage + * */ #include <linux/miscdevice.h> #include <linux/gfp.h> @@ -359,11 +363,15 @@ static int tgt_ring_init(struct tgt_ring ring->tr_pages[i] = get_zeroed_page(GFP_KERNEL); if (!ring->tr_pages[i]) { eprintk("out of memory\n"); - return -ENOMEM; + goto err; } } return 0; + err: + for (; --i >= 0;) + free_page(ring->tr_pages[i]); + return -ENOMEM; } void scsi_tgt_if_exit(void) -- To unsubscribe from this list: 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