Skip to contentSkip to conversation

net: sxgbe: fix null pointer dereference in probe error path

PATCH Applied Chenguang Zhao 3 participants 3 messages Jul 17 – Jul 22

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: sxgbe: fix null pointer dereference in probe error path

From: Chenguang Zhao <[email protected]>

The platform drvdata is not set until all IRQs have been mapped, so the local net_device pointer is NULL when IRQ mapping fails. Remove the device allocated by sxgbe_drv_probe() through priv instead.

Fixes 1edb9ca69e8a ("net: sxgbe: add basic framework for Samsung 10Gb ethernet driver")
---
 drivers/net/ethernet/samsung/sxgbe/sxgbe_platform.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/samsung/sxgbe/sxgbe_platform.c +1 -2
index 2eccc7617507..e4701b29e1a0 100644
@@ -82,7 +82,6 @@ static int sxgbe_platform_probe(struct platform_device *pdev)
 	void __iomem *addr;
 	struct sxgbe_priv_data *priv = NULL;
 	struct sxgbe_plat_data *plat_dat = NULL;
-	struct net_device *ndev = platform_get_drvdata(pdev);
 	struct device_node *node = dev->of_node;
 
 	/* Get memory resource */
@@ -158,7 +157,7 @@ static int sxgbe_platform_probe(struct platform_device *pdev)
 		irq_dispose_mapping(priv->txq[i]->irq_no);
 	irq_dispose_mapping(priv->irq);
 err_drv_remove:
-	sxgbe_drv_remove(ndev);
+	sxgbe_drv_remove(priv->dev);
 err_out:
 	return -ENODEV;
 }
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Chenguang Zhao

From: Chenguang Zhao <[email protected]>

The platform drvdata is not set until all IRQs have been mapped, so the local net_device pointer is NULL when IRQ mapping fails. Remove the device allocated by sxgbe_drv_probe() through priv instead.

Fixes 1edb9ca69e8a ("net: sxgbe: add basic framework for Samsung 10Gb ethernet driver")

Andrew

#2 lore raw
In reply to Chenguang Zhao
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 10 lines · On Fri, 17 Jul 2026 17:14:23 +0800 you wrote:

From: Chenguang Zhao <[email protected]>

The platform drvdata is not set until all IRQs have been mapped, so the local net_device pointer is NULL when IRQ mapping fails. Remove the device allocated by sxgbe_drv_probe() through priv instead.

Fixes 1edb9ca69e8a ("net: sxgbe: add basic framework for Samsung 10Gb ethernet driver")

[...]

Here is the summary with links:
- [net] net: sxgbe: fix null pointer dereference in probe error path

    https://git.kernel.org/netdev/net-next/c/1df10cef2d1e

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html