[PATCH] net/ne: fix memory leak in ne_drv_probe()

From: Kulikov Vasiliy
Date: Sat Jul 03 2010 - 11:20:52 EST


net_device allocated with alloc_eip_netdev() must be freed.

Signed-off-by: Kulikov Vasiliy <segooon@xxxxxxxxx>
---
drivers/net/ne.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/net/ne.c b/drivers/net/ne.c
index b8e2923..1063093 100644
--- a/drivers/net/ne.c
+++ b/drivers/net/ne.c
@@ -796,28 +796,30 @@ static int __init ne_drv_probe(struct platform_device *pdev)
dev = alloc_eip_netdev();
if (!dev)
return -ENOMEM;

/* ne.c doesn't populate resources in platform_device, but
* rbtx4927_ne_init and rbtx4938_ne_init do register devices
* with resources.
*/
res = platform_get_resource(pdev, IORESOURCE_IO, 0);
if (res) {
dev->base_addr = res->start;
dev->irq = platform_get_irq(pdev, 0);
} else {
- if (this_dev < 0 || this_dev >= MAX_NE_CARDS)
+ if (this_dev < 0 || this_dev >= MAX_NE_CARDS) {
+ free_netdev(dev);
return -EINVAL;
+ }
dev->base_addr = io[this_dev];
dev->irq = irq[this_dev];
dev->mem_end = bad[this_dev];
}
err = do_ne_probe(dev);
if (err) {
free_netdev(dev);
return err;
}
platform_set_drvdata(pdev, dev);

/* Update with any values found by probing, don't update if
* resources were specified.
--
1.7.0.4

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