mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-27 19:29:37 +00:00
net: ethernet: davinci_emac: fix error handling in probe()
The current error handling code has an issue where it does:
if (priv->txchan)
cpdma_chan_destroy(priv->txchan);
The problem is that ->txchan is either valid or an error pointer (which
would lead to an Oops). I've changed it to use multiple error labels so
that the test can be removed.
Also there were some missing calls to netif_napi_del().
Fixes: 3ef0fdb234
("net: davinci_emac: switch to new cpdma layer")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
0f51f3582f
commit
8005b09d99
1 changed files with 12 additions and 10 deletions
|
@ -1873,7 +1873,7 @@ static int davinci_emac_probe(struct platform_device *pdev)
|
||||||
if (IS_ERR(priv->txchan)) {
|
if (IS_ERR(priv->txchan)) {
|
||||||
dev_err(&pdev->dev, "error initializing tx dma channel\n");
|
dev_err(&pdev->dev, "error initializing tx dma channel\n");
|
||||||
rc = PTR_ERR(priv->txchan);
|
rc = PTR_ERR(priv->txchan);
|
||||||
goto no_cpdma_chan;
|
goto err_free_dma;
|
||||||
}
|
}
|
||||||
|
|
||||||
priv->rxchan = cpdma_chan_create(priv->dma, EMAC_DEF_RX_CH,
|
priv->rxchan = cpdma_chan_create(priv->dma, EMAC_DEF_RX_CH,
|
||||||
|
@ -1881,14 +1881,14 @@ static int davinci_emac_probe(struct platform_device *pdev)
|
||||||
if (IS_ERR(priv->rxchan)) {
|
if (IS_ERR(priv->rxchan)) {
|
||||||
dev_err(&pdev->dev, "error initializing rx dma channel\n");
|
dev_err(&pdev->dev, "error initializing rx dma channel\n");
|
||||||
rc = PTR_ERR(priv->rxchan);
|
rc = PTR_ERR(priv->rxchan);
|
||||||
goto no_cpdma_chan;
|
goto err_free_txchan;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
|
res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
|
||||||
if (!res) {
|
if (!res) {
|
||||||
dev_err(&pdev->dev, "error getting irq res\n");
|
dev_err(&pdev->dev, "error getting irq res\n");
|
||||||
rc = -ENOENT;
|
rc = -ENOENT;
|
||||||
goto no_cpdma_chan;
|
goto err_free_rxchan;
|
||||||
}
|
}
|
||||||
ndev->irq = res->start;
|
ndev->irq = res->start;
|
||||||
|
|
||||||
|
@ -1914,7 +1914,7 @@ static int davinci_emac_probe(struct platform_device *pdev)
|
||||||
pm_runtime_put_noidle(&pdev->dev);
|
pm_runtime_put_noidle(&pdev->dev);
|
||||||
dev_err(&pdev->dev, "%s: failed to get_sync(%d)\n",
|
dev_err(&pdev->dev, "%s: failed to get_sync(%d)\n",
|
||||||
__func__, rc);
|
__func__, rc);
|
||||||
goto no_cpdma_chan;
|
goto err_napi_del;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* register the network device */
|
/* register the network device */
|
||||||
|
@ -1924,7 +1924,7 @@ static int davinci_emac_probe(struct platform_device *pdev)
|
||||||
dev_err(&pdev->dev, "error in register_netdev\n");
|
dev_err(&pdev->dev, "error in register_netdev\n");
|
||||||
rc = -ENODEV;
|
rc = -ENODEV;
|
||||||
pm_runtime_put(&pdev->dev);
|
pm_runtime_put(&pdev->dev);
|
||||||
goto no_cpdma_chan;
|
goto err_napi_del;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1937,11 +1937,13 @@ static int davinci_emac_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
no_cpdma_chan:
|
err_napi_del:
|
||||||
if (priv->txchan)
|
netif_napi_del(&priv->napi);
|
||||||
cpdma_chan_destroy(priv->txchan);
|
err_free_rxchan:
|
||||||
if (priv->rxchan)
|
|
||||||
cpdma_chan_destroy(priv->rxchan);
|
cpdma_chan_destroy(priv->rxchan);
|
||||||
|
err_free_txchan:
|
||||||
|
cpdma_chan_destroy(priv->txchan);
|
||||||
|
err_free_dma:
|
||||||
cpdma_ctlr_destroy(priv->dma);
|
cpdma_ctlr_destroy(priv->dma);
|
||||||
no_pdata:
|
no_pdata:
|
||||||
if (of_phy_is_fixed_link(np))
|
if (of_phy_is_fixed_link(np))
|
||||||
|
|
Loading…
Reference in a new issue