aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2018-05-31 02:44:49 -0400
committerDavid S. Miller <davem@davemloft.net>2018-05-31 16:12:00 -0400
commit8005b09d99fac78e6f5fb9da30b5ae94840af03b (patch)
tree792ab5311bd824a95523f7489ee3344fa07bed6d
parent0f51f3582f22e543b78c4e113220ed1c35acbd97 (diff)
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: 3ef0fdb2342c ("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>
-rw-r--r--drivers/net/ethernet/ti/davinci_emac.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c
index abceea802ea1..38828ab77eb9 100644
--- a/drivers/net/ethernet/ti/davinci_emac.c
+++ b/drivers/net/ethernet/ti/davinci_emac.c
@@ -1873,7 +1873,7 @@ static int davinci_emac_probe(struct platform_device *pdev)
1873 if (IS_ERR(priv->txchan)) { 1873 if (IS_ERR(priv->txchan)) {
1874 dev_err(&pdev->dev, "error initializing tx dma channel\n"); 1874 dev_err(&pdev->dev, "error initializing tx dma channel\n");
1875 rc = PTR_ERR(priv->txchan); 1875 rc = PTR_ERR(priv->txchan);
1876 goto no_cpdma_chan; 1876 goto err_free_dma;
1877 } 1877 }
1878 1878
1879 priv->rxchan = cpdma_chan_create(priv->dma, EMAC_DEF_RX_CH, 1879 priv->rxchan = cpdma_chan_create(priv->dma, EMAC_DEF_RX_CH,
@@ -1881,14 +1881,14 @@ static int davinci_emac_probe(struct platform_device *pdev)
1881 if (IS_ERR(priv->rxchan)) { 1881 if (IS_ERR(priv->rxchan)) {
1882 dev_err(&pdev->dev, "error initializing rx dma channel\n"); 1882 dev_err(&pdev->dev, "error initializing rx dma channel\n");
1883 rc = PTR_ERR(priv->rxchan); 1883 rc = PTR_ERR(priv->rxchan);
1884 goto no_cpdma_chan; 1884 goto err_free_txchan;
1885 } 1885 }
1886 1886
1887 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 1887 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
1888 if (!res) { 1888 if (!res) {
1889 dev_err(&pdev->dev, "error getting irq res\n"); 1889 dev_err(&pdev->dev, "error getting irq res\n");
1890 rc = -ENOENT; 1890 rc = -ENOENT;
1891 goto no_cpdma_chan; 1891 goto err_free_rxchan;
1892 } 1892 }
1893 ndev->irq = res->start; 1893 ndev->irq = res->start;
1894 1894
@@ -1914,7 +1914,7 @@ static int davinci_emac_probe(struct platform_device *pdev)
1914 pm_runtime_put_noidle(&pdev->dev); 1914 pm_runtime_put_noidle(&pdev->dev);
1915 dev_err(&pdev->dev, "%s: failed to get_sync(%d)\n", 1915 dev_err(&pdev->dev, "%s: failed to get_sync(%d)\n",
1916 __func__, rc); 1916 __func__, rc);
1917 goto no_cpdma_chan; 1917 goto err_napi_del;
1918 } 1918 }
1919 1919
1920 /* register the network device */ 1920 /* register the network device */
@@ -1924,7 +1924,7 @@ static int davinci_emac_probe(struct platform_device *pdev)
1924 dev_err(&pdev->dev, "error in register_netdev\n"); 1924 dev_err(&pdev->dev, "error in register_netdev\n");
1925 rc = -ENODEV; 1925 rc = -ENODEV;
1926 pm_runtime_put(&pdev->dev); 1926 pm_runtime_put(&pdev->dev);
1927 goto no_cpdma_chan; 1927 goto err_napi_del;
1928 } 1928 }
1929 1929
1930 1930
@@ -1937,11 +1937,13 @@ static int davinci_emac_probe(struct platform_device *pdev)
1937 1937
1938 return 0; 1938 return 0;
1939 1939
1940no_cpdma_chan: 1940err_napi_del:
1941 if (priv->txchan) 1941 netif_napi_del(&priv->napi);
1942 cpdma_chan_destroy(priv->txchan); 1942err_free_rxchan:
1943 if (priv->rxchan) 1943 cpdma_chan_destroy(priv->rxchan);
1944 cpdma_chan_destroy(priv->rxchan); 1944err_free_txchan:
1945 cpdma_chan_destroy(priv->txchan);
1946err_free_dma:
1945 cpdma_ctlr_destroy(priv->dma); 1947 cpdma_ctlr_destroy(priv->dma);
1946no_pdata: 1948no_pdata:
1947 if (of_phy_is_fixed_link(np)) 1949 if (of_phy_is_fixed_link(np))