Thread (4 messages) 4 messages, 3 authors, 2026-01-02

RE: [PATCH] net: mediatek: add null pointer check for hardware offloading

From: Sai Krishna Gajula <hidden>
Date: 2026-01-01 16:04:46
Also in: linux-arm-kernel, linux-mediatek, lkml

quoted hunk ↗ jump to hunk
-----Original Message-----
From: Sebastian Roland Wolf <redacted>
Sent: Thursday, January 1, 2026 4:22 AM
To: Felix Fietkau <nbd@nbd.name>; Sean Wang
[off-list ref]; Lorenzo Bianconi [off-list ref]
Cc: Andrew Lunn <andrew+netdev@lunn.ch>; Matthias Brugger
[off-list ref]; AngeloGioacchino Del Regno
[off-list ref]; netdev@vger.kernel.org; linux-
kernel@vger.kernel.org; linux-arm-kernel@lists.infradead.org; linux-
mediatek@lists.infradead.org; Sebastian Roland Wolf
[off-list ref]; Sebastian Roland Wolf
[off-list ref]
Subject:  [PATCH] net: mediatek: add null pointer check for
hardware offloading

From: Sebastian Roland Wolf <srw@ root533. premium-rootserver. net> Add a
null pointer check to prevent kernel crashes when hardware offloading is
active on MediaTek devices. In some edge cases, the ethernet pointer or its
associated netdev 
From: Sebastian Roland Wolf <redacted>

Add a null pointer check to prevent kernel crashes when hardware offloading
is active on MediaTek devices.

In some edge cases, the ethernet pointer or its associated netdev element
can be NULL. Checking these pointers before access is mandatory to avoid
segmentation faults and kernel oops.

This improves the robustness of the validation check for mtk_eth ingress
devices introduced in commit 73cfd947dbdb ("net: mediatek:
add support for ingress traffic offloading").

Fixes: 73cfd947dbdb ("net: mediatek: add support for ingress traffic
offloading")
net: mediatek: Add null pointer check to prevent crashes with active hardware
offloading.

Signed-off-by: Sebastian Roland Wolf <redacted>
---
 drivers/net/ethernet/mediatek/mtk_ppe_offload.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/mediatek/mtk_ppe_offload.c
b/drivers/net/ethernet/mediatek/mtk_ppe_offload.c
index e9bd32741983..6900ac87e1e9 100644
--- a/drivers/net/ethernet/mediatek/mtk_ppe_offload.c
+++ b/drivers/net/ethernet/mediatek/mtk_ppe_offload.c
@@ -270,7 +270,8 @@ mtk_flow_offload_replace(struct mtk_eth *eth, struct
flow_cls_offload *f,
 		flow_rule_match_meta(rule, &match);
 		if (mtk_is_netsys_v2_or_greater(eth)) {
 			idev = __dev_get_by_index(&init_net, match.key-
quoted
ingress_ifindex);
-			if (idev && idev->netdev_ops == eth->netdev[0]-
quoted
netdev_ops) {
+			if (idev && eth && eth->netdev[0] &&
+			    idev->netdev_ops == eth->netdev[0]->netdev_ops)
{
 				struct mtk_mac *mac = netdev_priv(idev);

 				if (WARN_ON(mac->ppe_idx >= eth->soc-
quoted
ppe_num))
--
2.51.0
Reviewed-by: Sai Krishna <redacted>
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help