aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/pxa168_eth.c
diff options
context:
space:
mode:
authorDan Carpenter <error27@gmail.com>2010-08-24 02:53:33 -0400
committerDavid S. Miller <davem@davemloft.net>2010-08-24 17:50:26 -0400
commit945c7c73e2e81d68e3e2970afd95254e8f153fc9 (patch)
treecfbeb347dbc281bc786b591396d180f8ef051778 /drivers/net/pxa168_eth.c
parent4169591fd7c260b2b0b4e8f4d51f63f5b15ad78a (diff)
pxa168_eth: fix error handling in prope
A couple issues here: * Some resources weren't released. * If alloc_etherdev() failed it would have caused a NULL dereference because "pep" would be null when we checked "if (pep->clk)". * Also it's better to propagate the error codes from mdiobus_register() instead of just returning -ENOMEM. Signed-off-by: Dan Carpenter <error27@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/pxa168_eth.c')
-rw-r--r--drivers/net/pxa168_eth.c44
1 files changed, 22 insertions, 22 deletions
diff --git a/drivers/net/pxa168_eth.c b/drivers/net/pxa168_eth.c
index 857a68115a5c..302fb480374b 100644
--- a/drivers/net/pxa168_eth.c
+++ b/drivers/net/pxa168_eth.c
@@ -1497,7 +1497,7 @@ static int pxa168_eth_probe(struct platform_device *pdev)
1497 dev = alloc_etherdev(sizeof(struct pxa168_eth_private)); 1497 dev = alloc_etherdev(sizeof(struct pxa168_eth_private));
1498 if (!dev) { 1498 if (!dev) {
1499 err = -ENOMEM; 1499 err = -ENOMEM;
1500 goto out; 1500 goto err_clk;
1501 } 1501 }
1502 1502
1503 platform_set_drvdata(pdev, dev); 1503 platform_set_drvdata(pdev, dev);
@@ -1507,12 +1507,12 @@ static int pxa168_eth_probe(struct platform_device *pdev)
1507 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1507 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1508 if (res == NULL) { 1508 if (res == NULL) {
1509 err = -ENODEV; 1509 err = -ENODEV;
1510 goto out; 1510 goto err_netdev;
1511 } 1511 }
1512 pep->base = ioremap(res->start, res->end - res->start + 1); 1512 pep->base = ioremap(res->start, res->end - res->start + 1);
1513 if (pep->base == NULL) { 1513 if (pep->base == NULL) {
1514 err = -ENOMEM; 1514 err = -ENOMEM;
1515 goto out; 1515 goto err_netdev;
1516 } 1516 }
1517 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 1517 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
1518 BUG_ON(!res); 1518 BUG_ON(!res);
@@ -1549,7 +1549,7 @@ static int pxa168_eth_probe(struct platform_device *pdev)
1549 pep->smi_bus = mdiobus_alloc(); 1549 pep->smi_bus = mdiobus_alloc();
1550 if (pep->smi_bus == NULL) { 1550 if (pep->smi_bus == NULL) {
1551 err = -ENOMEM; 1551 err = -ENOMEM;
1552 goto out; 1552 goto err_base;
1553 } 1553 }
1554 pep->smi_bus->priv = pep; 1554 pep->smi_bus->priv = pep;
1555 pep->smi_bus->name = "pxa168_eth smi"; 1555 pep->smi_bus->name = "pxa168_eth smi";
@@ -1558,31 +1558,31 @@ static int pxa168_eth_probe(struct platform_device *pdev)
1558 snprintf(pep->smi_bus->id, MII_BUS_ID_SIZE, "%d", pdev->id); 1558 snprintf(pep->smi_bus->id, MII_BUS_ID_SIZE, "%d", pdev->id);
1559 pep->smi_bus->parent = &pdev->dev; 1559 pep->smi_bus->parent = &pdev->dev;
1560 pep->smi_bus->phy_mask = 0xffffffff; 1560 pep->smi_bus->phy_mask = 0xffffffff;
1561 if (mdiobus_register(pep->smi_bus) < 0) { 1561 err = mdiobus_register(pep->smi_bus);
1562 err = -ENOMEM; 1562 if (err)
1563 goto out; 1563 goto err_free_mdio;
1564 } 1564
1565 pxa168_init_hw(pep); 1565 pxa168_init_hw(pep);
1566 err = ethernet_phy_setup(dev); 1566 err = ethernet_phy_setup(dev);
1567 if (err) 1567 if (err)
1568 goto out; 1568 goto err_mdiobus;
1569 SET_NETDEV_DEV(dev, &pdev->dev); 1569 SET_NETDEV_DEV(dev, &pdev->dev);
1570 err = register_netdev(dev); 1570 err = register_netdev(dev);
1571 if (err) 1571 if (err)
1572 goto out; 1572 goto err_mdiobus;
1573 return 0; 1573 return 0;
1574out: 1574
1575 if (pep->clk) { 1575err_mdiobus:
1576 clk_disable(pep->clk); 1576 mdiobus_unregister(pep->smi_bus);
1577 clk_put(pep->clk); 1577err_free_mdio:
1578 pep->clk = NULL; 1578 mdiobus_free(pep->smi_bus);
1579 } 1579err_base:
1580 if (pep->base) { 1580 iounmap(pep->base);
1581 iounmap(pep->base); 1581err_netdev:
1582 pep->base = NULL; 1582 free_netdev(dev);
1583 } 1583err_clk:
1584 if (dev) 1584 clk_disable(clk);
1585 free_netdev(dev); 1585 clk_put(clk);
1586 return err; 1586 return err;
1587} 1587}
1588 1588