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>
This commit is contained in:
parent
3630d40067
commit
c9324d1870
|
@ -1552,7 +1552,7 @@ static int stmmac_open(struct net_device *dev)
|
||||||
if (ret) {
|
if (ret) {
|
||||||
pr_err("%s: Cannot attach to PHY (error: %d)\n",
|
pr_err("%s: Cannot attach to PHY (error: %d)\n",
|
||||||
__func__, ret);
|
__func__, ret);
|
||||||
goto open_error;
|
goto phy_error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1566,7 +1566,7 @@ static int stmmac_open(struct net_device *dev)
|
||||||
ret = stmmac_init_dma_engine(priv);
|
ret = stmmac_init_dma_engine(priv);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
pr_err("%s: DMA initialization failed\n", __func__);
|
pr_err("%s: DMA initialization failed\n", __func__);
|
||||||
goto open_error;
|
goto init_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Copy the MAC addr into the HW */
|
/* Copy the MAC addr into the HW */
|
||||||
|
@ -1585,7 +1585,7 @@ static int stmmac_open(struct net_device *dev)
|
||||||
if (unlikely(ret < 0)) {
|
if (unlikely(ret < 0)) {
|
||||||
pr_err("%s: ERROR: allocating the IRQ %d (error: %d)\n",
|
pr_err("%s: ERROR: allocating the IRQ %d (error: %d)\n",
|
||||||
__func__, dev->irq, ret);
|
__func__, dev->irq, ret);
|
||||||
goto open_error;
|
goto init_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Request the Wake IRQ in case of another line is used for WoL */
|
/* 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)
|
||||||
if (unlikely(ret < 0)) {
|
if (unlikely(ret < 0)) {
|
||||||
pr_err("%s: ERROR: allocating the WoL IRQ %d (%d)\n",
|
pr_err("%s: ERROR: allocating the WoL IRQ %d (%d)\n",
|
||||||
__func__, priv->wol_irq, ret);
|
__func__, priv->wol_irq, ret);
|
||||||
goto open_error_wolirq;
|
goto wolirq_error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1606,7 +1606,7 @@ static int stmmac_open(struct net_device *dev)
|
||||||
if (unlikely(ret < 0)) {
|
if (unlikely(ret < 0)) {
|
||||||
pr_err("%s: ERROR: allocating the LPI IRQ %d (%d)\n",
|
pr_err("%s: ERROR: allocating the LPI IRQ %d (%d)\n",
|
||||||
__func__, priv->lpi_irq, ret);
|
__func__, priv->lpi_irq, ret);
|
||||||
goto open_error_lpiirq;
|
goto lpiirq_error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1664,17 +1664,17 @@ static int stmmac_open(struct net_device *dev)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
open_error_lpiirq:
|
lpiirq_error:
|
||||||
if (priv->wol_irq != dev->irq)
|
if (priv->wol_irq != dev->irq)
|
||||||
free_irq(priv->wol_irq, dev);
|
free_irq(priv->wol_irq, dev);
|
||||||
|
wolirq_error:
|
||||||
open_error_wolirq:
|
|
||||||
free_irq(dev->irq, dev);
|
free_irq(dev->irq, dev);
|
||||||
|
|
||||||
open_error:
|
init_error:
|
||||||
|
free_dma_desc_resources(priv);
|
||||||
if (priv->phydev)
|
if (priv->phydev)
|
||||||
phy_disconnect(priv->phydev);
|
phy_disconnect(priv->phydev);
|
||||||
|
phy_error:
|
||||||
clk_disable_unprepare(priv->stmmac_clk);
|
clk_disable_unprepare(priv->stmmac_clk);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Reference in New Issue