d715c4aa6867b999522556463fc8accfd574aff9
[openwrt/staging/thess.git] /
1 From 7c83e28f10830aa5105c25eaabe890e3adac36aa Mon Sep 17 00:00:00 2001
2 From: Daniel Golle <daniel@makrotopia.org>
3 Date: Tue, 9 May 2023 03:20:06 +0200
4 Subject: [PATCH] net: ethernet: mtk_eth_soc: fix NULL pointer dereference
5
6 Check for NULL pointer to avoid kernel crashing in case of missing WO
7 firmware in case only a single WEDv2 device has been initialized, e.g. on
8 MT7981 which can connect just one wireless frontend.
9
10 Fixes: 86ce0d09e424 ("net: ethernet: mtk_eth_soc: use WO firmware for MT7981")
11 Signed-off-by: Daniel Golle <daniel@makrotopia.org>
12 Reviewed-by: Simon Horman <simon.horman@corigine.com>
13 Signed-off-by: David S. Miller <davem@davemloft.net>
14 ---
15 drivers/net/ethernet/mediatek/mtk_wed.c | 2 +-
16 1 file changed, 1 insertion(+), 1 deletion(-)
17
18 --- a/drivers/net/ethernet/mediatek/mtk_wed.c
19 +++ b/drivers/net/ethernet/mediatek/mtk_wed.c
20 @@ -647,7 +647,7 @@ __mtk_wed_detach(struct mtk_wed_device *
21 BIT(hw->index), BIT(hw->index));
22 }
23
24 - if (!hw_list[!hw->index]->wed_dev &&
25 + if ((!hw_list[!hw->index] || !hw_list[!hw->index]->wed_dev) &&
26 hw->eth->dma_dev != hw->eth->dev)
27 mtk_eth_set_dma_device(hw->eth, hw->eth->dev);
28