[PATCH] drivers/net/ewrk.c memory leak

Hollis Blanchard (hollis@austin.ibm.com)
Fri, 23 May 2003 13:55:13 -0500


--Apple-Mail-11-246986084
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=US-ASCII;
format=flowed

Hi, this was caught by the Stanford memory leak checker a while ago
(2.5.48). If the tmp_stats allocation fails, tmp is not being freed.

-- 
Hollis Blanchard
IBM Linux Technology Center

--Apple-Mail-11-246986084 Content-Disposition: attachment; filename=ewrk3-memleak.diff Content-Transfer-Encoding: 7bit Content-Type: application/octet-stream; x-unix-mode=0644; name="ewrk3-memleak.diff"

--- drivers/net/ewrk3.c.orig 2003-05-13 13:51:55.000000000 -0500 +++ drivers/net/ewrk3.c 2003-05-13 13:54:55.000000000 -0500 @@ -1968,7 +1968,10 @@ case EWRK3_GET_STATS: { /* Get the driver statistics */ struct ewrk3_stats *tmp_stats = kmalloc(sizeof(lp->pktStats), GFP_KERNEL); - if (!tmp_stats) return -ENOMEM; + if (!tmp_stats) { + status = -ENOMEM; + break; + } spin_lock_irqsave(&lp->hw_lock, flags); memcpy(tmp_stats, &lp->pktStats, sizeof(lp->pktStats));

--Apple-Mail-11-246986084--

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/