aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorGiuseppe CAVALLARO <peppe.cavallaro@st.com>2013-07-04 00:18:07 -0400
committerDavid S. Miller <davem@davemloft.net>2013-07-04 17:34:16 -0400
commitc9324d1870f3a7d13297ae6b787c567606ab3c89 (patch)
treec6608f81614d5f8e8fecb0bd7577890dc6c475a7 /drivers/net
parent3630d40067a21d4dfbadc6002bb469ce26ac5d52 (diff)
net:stmmac: fix memleak in the open method
This patch is to fix a memory leak in the open method, it reviews error conditions freeing the resources previously allocated and not freed in cased of DMA failure. Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_main.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index f2d283d2528f..f2ccb36e8685 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1552,7 +1552,7 @@ static int stmmac_open(struct net_device *dev)
1552 if (ret) { 1552 if (ret) {
1553 pr_err("%s: Cannot attach to PHY (error: %d)\n", 1553 pr_err("%s: Cannot attach to PHY (error: %d)\n",
1554 __func__, ret); 1554 __func__, ret);
1555 goto open_error; 1555 goto phy_error;
1556 } 1556 }
1557 } 1557 }
1558 1558
@@ -1566,7 +1566,7 @@ static int stmmac_open(struct net_device *dev)
1566 ret = stmmac_init_dma_engine(priv); 1566 ret = stmmac_init_dma_engine(priv);
1567 if (ret < 0) { 1567 if (ret < 0) {
1568 pr_err("%s: DMA initialization failed\n", __func__); 1568 pr_err("%s: DMA initialization failed\n", __func__);
1569 goto open_error; 1569 goto init_error;
1570 } 1570 }
1571 1571
1572 /* Copy the MAC addr into the HW */ 1572 /* Copy the MAC addr into the HW */
@@ -1585,7 +1585,7 @@ static int stmmac_open(struct net_device *dev)
1585 if (unlikely(ret < 0)) { 1585 if (unlikely(ret < 0)) {
1586 pr_err("%s: ERROR: allocating the IRQ %d (error: %d)\n", 1586 pr_err("%s: ERROR: allocating the IRQ %d (error: %d)\n",
1587 __func__, dev->irq, ret); 1587 __func__, dev->irq, ret);
1588 goto open_error; 1588 goto init_error;
1589 } 1589 }
1590 1590
1591 /* Request the Wake IRQ in case of another line is used for WoL */ 1591 /* Request the Wake IRQ in case of another line is used for WoL */
@@ -1595,7 +1595,7 @@ static int stmmac_open(struct net_device *dev)
1595 if (unlikely(ret < 0)) { 1595 if (unlikely(ret < 0)) {
1596 pr_err("%s: ERROR: allocating the WoL IRQ %d (%d)\n", 1596 pr_err("%s: ERROR: allocating the WoL IRQ %d (%d)\n",
1597 __func__, priv->wol_irq, ret); 1597 __func__, priv->wol_irq, ret);
1598 goto open_error_wolirq; 1598 goto wolirq_error;
1599 } 1599 }
1600 } 1600 }
1601 1601
@@ -1606,7 +1606,7 @@ static int stmmac_open(struct net_device *dev)
1606 if (unlikely(ret < 0)) { 1606 if (unlikely(ret < 0)) {
1607 pr_err("%s: ERROR: allocating the LPI IRQ %d (%d)\n", 1607 pr_err("%s: ERROR: allocating the LPI IRQ %d (%d)\n",
1608 __func__, priv->lpi_irq, ret); 1608 __func__, priv->lpi_irq, ret);
1609 goto open_error_lpiirq; 1609 goto lpiirq_error;
1610 } 1610 }
1611 } 1611 }
1612 1612
@@ -1664,17 +1664,17 @@ static int stmmac_open(struct net_device *dev)
1664 1664
1665 return 0; 1665 return 0;
1666 1666
1667open_error_lpiirq: 1667lpiirq_error:
1668 if (priv->wol_irq != dev->irq) 1668 if (priv->wol_irq != dev->irq)
1669 free_irq(priv->wol_irq, dev); 1669 free_irq(priv->wol_irq, dev);
1670 1670wolirq_error:
1671open_error_wolirq:
1672 free_irq(dev->irq, dev); 1671 free_irq(dev->irq, dev);
1673 1672
1674open_error: 1673init_error:
1674 free_dma_desc_resources(priv);
1675 if (priv->phydev) 1675 if (priv->phydev)
1676 phy_disconnect(priv->phydev); 1676 phy_disconnect(priv->phydev);
1677 1677phy_error:
1678 clk_disable_unprepare(priv->stmmac_clk); 1678 clk_disable_unprepare(priv->stmmac_clk);
1679 1679
1680 return ret; 1680 return ret;