Patchwork tokenring/3c359.c: Prevent possible mem leak when open failed

login
register
mail settings
Submitter Jirka Pirko
Date Nov. 23, 2008, 8:44 p.m.
Message ID <20081123214410.44810f99@jirka.pirko.cz>
Download mbox | patch
Permalink /patch/10335/
State Accepted
Delegated to: David Miller
Headers show

Comments

Jirka Pirko - Nov. 23, 2008, 8:44 p.m.
Freeing previously allocated buffers in case of error.

Signed-off-by: Jirka Pirko <jirka@pirko.cz>
---
 drivers/net/tokenring/3c359.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
David Miller - Nov. 24, 2008, 10:49 p.m.
From: Jirka Pirko <jirka@pirko.cz>
Date: Sun, 23 Nov 2008 21:44:10 +0100

> Freeing previously allocated buffers in case of error.
> 
> Signed-off-by: Jirka Pirko <jirka@pirko.cz>

Applied.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/net/tokenring/3c359.c b/drivers/net/tokenring/3c359.c
index 46fb308..4bb9ca8 100644
--- a/drivers/net/tokenring/3c359.c
+++ b/drivers/net/tokenring/3c359.c
@@ -669,6 +669,8 @@  static int xl_open(struct net_device *dev)
 	if (i==0) { 
 		printk(KERN_WARNING "%s: Not enough memory to allocate rx buffers. Adapter disabled \n",dev->name) ; 
 		free_irq(dev->irq,dev) ; 
+		kfree(xl_priv->xl_tx_ring);
+		kfree(xl_priv->xl_rx_ring);
 		return -EIO ; 
 	}