Skip to content

Commit

Permalink
net: nixge: fix potential memory leak in nixge_probe()
Browse files Browse the repository at this point in the history
[ Upstream commit 366228e ]

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

Fixes: 87ab207 ("net: nixge: Separate ctrl and dma resources")
Fixes: abcd3d6 ("net: nixge: Fix error path for obtaining mac address")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Lu Wei <luwei32@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Lu Wei authored and gregkh committed Aug 5, 2020
1 parent 9acd96f commit 1158aa7
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions drivers/net/ethernet/ni/nixge.c
Expand Up @@ -1318,19 +1318,21 @@ static int nixge_probe(struct platform_device *pdev)
netif_napi_add(ndev, &priv->napi, nixge_poll, NAPI_POLL_WEIGHT);
err = nixge_of_get_resources(pdev);
if (err)
return err;
goto free_netdev;
__nixge_hw_set_mac_address(ndev);

priv->tx_irq = platform_get_irq_byname(pdev, "tx");
if (priv->tx_irq < 0) {
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");
if (priv->rx_irq < 0) {
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;
Expand Down

0 comments on commit 1158aa7

Please sign in to comment.