Skip to contentSkip to conversation

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

PATCH Applied Lu Wei 2 participants 2 messages Jul 29, 2020 – Jul 30, 2020

Subsystems (2)
lore
Share & tools
lore

Lu Wei

author
#0 lore raw

PATCH 1/1 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 87ab207981ec ("net: nixge: Separate ctrl and dma resources")
Fixes abcd3d6fc640 ("net: nixge: Fix error path for obtaining mac address")
---
 drivers/net/ethernet/ni/nixge.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/net/ethernet/ni/nixge.c +5 -3
index d2708a57f2ff..4075f5e59955 100644
@@ -1299,19 +1299,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;
Signature · 1 line
2.17.1
maintainer Applied
#1 lore raw

From: Lu Wei <[email protected]>
Date: Wed, 29 Jul 2020 11:50:05 +0800

Quoted 7 lines

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

Fixes 87ab207981ec ("net: nixge: Separate ctrl and dma resources")
Fixes abcd3d6fc640 ("net: nixge: Fix error path for obtaining mac address")

Applied, thank you.