fc6e2464688cc39e49fa705c723c8731605edb3e
[openwrt/staging/jogo.git] /
1 From: Lorenzo Bianconi <lorenzo@kernel.org>
2 Date: Mon, 18 Jul 2022 11:51:53 +0200
3 Subject: [PATCH] net: ethernet: mtk_ppe: fix possible NULL pointer dereference
4 in mtk_flow_get_wdma_info
5
6 odev pointer can be NULL in mtk_flow_offload_replace routine according
7 to the flower action rules. Fix possible NULL pointer dereference in
8 mtk_flow_get_wdma_info.
9
10 Fixes: a333215e10cb5 ("net: ethernet: mtk_eth_soc: implement flow offloading to WED devices")
11 Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
12 Link: https://lore.kernel.org/r/4e1685bc4976e21e364055f6bee86261f8f9ee93.1658137753.git.lorenzo@kernel.org
13 Signed-off-by: Jakub Kicinski <kuba@kernel.org>
14 ---
15
16 --- a/drivers/net/ethernet/mediatek/mtk_ppe_offload.c
17 +++ b/drivers/net/ethernet/mediatek/mtk_ppe_offload.c
18 @@ -93,6 +93,9 @@ mtk_flow_get_wdma_info(struct net_device
19 };
20 struct net_device_path path = {};
21
22 + if (!ctx.dev)
23 + return -ENODEV;
24 +
25 memcpy(ctx.daddr, addr, sizeof(ctx.daddr));
26
27 if (!IS_ENABLED(CONFIG_NET_MEDIATEK_SOC_WED))