Commit 366228ed authored by Lu Wei's avatar Lu Wei Committed by David S. Miller

net: nixge: fix potential memory leak in nixge_probe()

If some processes in nixge_probe() fail, free_netdev(dev)
needs to be called to aviod a memory leak.

Fixes: 87ab2079 ("net: nixge: Separate ctrl and dma resources")
Fixes: abcd3d6f ("net: nixge: Fix error path for obtaining mac address")
Reported-by: default avatarHulk Robot <hulkci@huawei.com>
Signed-off-by: default avatarLu Wei <luwei32@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 82274d07
...@@ -1299,19 +1299,21 @@ static int nixge_probe(struct platform_device *pdev) ...@@ -1299,19 +1299,21 @@ static int nixge_probe(struct platform_device *pdev)
netif_napi_add(ndev, &priv->napi, nixge_poll, NAPI_POLL_WEIGHT); netif_napi_add(ndev, &priv->napi, nixge_poll, NAPI_POLL_WEIGHT);
err = nixge_of_get_resources(pdev); err = nixge_of_get_resources(pdev);
if (err) if (err)
return err; goto free_netdev;
__nixge_hw_set_mac_address(ndev); __nixge_hw_set_mac_address(ndev);
priv->tx_irq = platform_get_irq_byname(pdev, "tx"); priv->tx_irq = platform_get_irq_byname(pdev, "tx");
if (priv->tx_irq < 0) { if (priv->tx_irq < 0) {
netdev_err(ndev, "could not find 'tx' irq"); netdev_err(ndev, "could not find 'tx' irq");
return priv->tx_irq; err = priv->tx_irq;
goto free_netdev;
} }
priv->rx_irq = platform_get_irq_byname(pdev, "rx"); priv->rx_irq = platform_get_irq_byname(pdev, "rx");
if (priv->rx_irq < 0) { if (priv->rx_irq < 0) {
netdev_err(ndev, "could not find 'rx' irq"); netdev_err(ndev, "could not find 'rx' irq");
return priv->rx_irq; err = priv->rx_irq;
goto free_netdev;
} }
priv->coalesce_count_rx = XAXIDMA_DFT_RX_THRESHOLD; priv->coalesce_count_rx = XAXIDMA_DFT_RX_THRESHOLD;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment