netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] 3c59x: Fix memory leaks in vortex_open
@ 2014-12-23  2:54 Jia-Ju Bai
  2014-12-23 14:24 ` Neil Horman
  0 siblings, 1 reply; 7+ messages in thread
From: Jia-Ju Bai @ 2014-12-23  2:54 UTC (permalink / raw)
  To: davem, nhorman, ebiederm, dingtianhong, paul.gortmaker,
	justinvanwijngaarden
  Cc: netdev, Jia-Ju Bai

For linux-3.18.0
The driver calls __netdev_alloc_skb in vortex_open but lacks dev_kfree_skb
when vortex_up is failed, so memory leaks may occur in this situation.
This patch fixes this problem.

Signed-off-by: Jia-Ju Bai <baijiaju1990@163.com>
---
 drivers/net/ethernet/3com/3c59x.c |   10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/net/ethernet/3com/3c59x.c b/drivers/net/ethernet/3com/3c59x.c
index 41095eb..d0c5bee 100644
--- a/drivers/net/ethernet/3com/3c59x.c
+++ b/drivers/net/ethernet/3com/3c59x.c
@@ -1782,6 +1782,16 @@ vortex_open(struct net_device *dev)
 	if (!retval)
 		goto out;
 
+	if (vp->full_bus_master_rx) {
+		for (i = 0; i < RX_RING_SIZE; i++) {
+			if (vp->rx_skbuff[i]) {
+				dev_kfree_skb(vp->rx_skbuff[i]);
+				vp->rx_skbuff[i] = NULL;
+			}
+		}
+		retval = -ENOMEM;
+	}
+
 err_free_irq:
 	free_irq(dev->irq, dev);
 err:
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-12-24  4:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-23  2:54 [PATCH v3] 3c59x: Fix memory leaks in vortex_open Jia-Ju Bai
2014-12-23 14:24 ` Neil Horman
2014-12-23 15:00   ` Jia-Ju Bai
2014-12-23 15:43     ` Neil Horman
2014-12-24  2:12       ` Jia-Ju Bai
2014-12-24  3:27         ` Neil Horman
2014-12-24  4:10           ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).