aboutsummaryrefslogtreecommitdiff
path: root/drivers/net/fec.c
diff options
context:
space:
mode:
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>2011-01-13 21:44:18 +0100
committerUwe Kleine-König <u.kleine-koenig@pengutronix.de>2011-02-15 09:26:28 +0100
commit28e2188efc614c714c69dd5c3f063e066e80d3ba (patch)
treee9db61aa5324f31d051efdaef6d898db7a384f8d /drivers/net/fec.c
parent8a73b0bc86366113e13d079b3de76df6e94a4a5c (diff)
net/fec: release mem_region requested in probe in error path and remove
Reported-by: Lothar Waßmann <LW@KARO-electronics.de> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Diffstat (limited to 'drivers/net/fec.c')
-rw-r--r--drivers/net/fec.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/drivers/net/fec.c b/drivers/net/fec.c
index 3e6e923ca59..b079826586e 100644
--- a/drivers/net/fec.c
+++ b/drivers/net/fec.c
@@ -1377,8 +1377,10 @@ fec_probe(struct platform_device *pdev)
/* Init network device */
ndev = alloc_etherdev(sizeof(struct fec_enet_private));
- if (!ndev)
- return -ENOMEM;
+ if (!ndev) {
+ ret = -ENOMEM;
+ goto failed_alloc_etherdev;
+ }
SET_NETDEV_DEV(ndev, &pdev->dev);
@@ -1456,6 +1458,8 @@ failed_irq:
iounmap((void __iomem *)ndev->base_addr);
failed_ioremap:
free_netdev(ndev);
+failed_alloc_etherdev:
+ release_mem_region(r->start, resource_size(r));
return ret;
}
@@ -1465,6 +1469,7 @@ fec_drv_remove(struct platform_device *pdev)
{
struct net_device *ndev = platform_get_drvdata(pdev);
struct fec_enet_private *fep = netdev_priv(ndev);
+ struct resource *r;
platform_set_drvdata(pdev, NULL);
@@ -1475,6 +1480,11 @@ fec_drv_remove(struct platform_device *pdev)
iounmap((void __iomem *)ndev->base_addr);
unregister_netdev(ndev);
free_netdev(ndev);
+
+ r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ BUG_ON(!r);
+ release_mem_region(r->start, resource_size(r));
+
return 0;
}