Skip to contentSkip to conversation

net: ethernet: mtk_eth_soc: fix NULL pointer dereference

PATCH Applied Daniel Golle 3 participants 3 messages May 9, 2023 – May 10, 2023

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

PATCH 1/1 net: ethernet: mtk_eth_soc: fix NULL pointer dereference

Check for NULL pointer to avoid kernel crashing in case of missing WO firmware in case only a single WEDv2 device has been initialized, e.g. on MT7981 which can connect just one wireless frontend.

Fixes 86ce0d09e424 ("net: ethernet: mtk_eth_soc: use WO firmware for MT7981")
---
 drivers/net/ethernet/mediatek/mtk_wed.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mediatek/mtk_wed.c +1 -1
index 4c205afbd230..985cff910f30 100644
@@ -654,7 +654,7 @@ __mtk_wed_detach(struct mtk_wed_device *dev)
 					   BIT(hw->index), BIT(hw->index));
 	}
 
-	if (!hw_list[!hw->index]->wed_dev &&
+	if ((!hw_list[!hw->index] || !hw_list[!hw->index]->wed_dev) &&
 	    hw->eth->dma_dev != hw->eth->dev)
 		mtk_eth_set_dma_device(hw->eth, hw->eth->dev);
 
Signature · 1 line
2.40.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Daniel Golle

Check for NULL pointer to avoid kernel crashing in case of missing WO firmware in case only a single WEDv2 device has been initialized, e.g. on MT7981 which can connect just one wireless frontend.

Fixes 86ce0d09e424 ("net: ethernet: mtk_eth_soc: use WO firmware for MT7981")
#2 lore raw
In reply to Daniel Golle
This patch was applied to netdev/net.git (main) by David S. Miller <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by David S. Miller <[email protected]>:

Quoted 8 lines · On Tue, 9 May 2023 03:20:06 +0200 you wrote:

Check for NULL pointer to avoid kernel crashing in case of missing WO firmware in case only a single WEDv2 device has been initialized, e.g. on MT7981 which can connect just one wireless frontend.

Fixes 86ce0d09e424 ("net: ethernet: mtk_eth_soc: use WO firmware for MT7981")

[...]

Here is the summary with links:
- [net] net: ethernet: mtk_eth_soc: fix NULL pointer dereference

    https://git.kernel.org/netdev/net/c/7c83e28f1083

You are awesome, thank you!

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