drivers/net/ethernet/mediatek/mtk_ppe_offload.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
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
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 <Sebastian.Wolf@pace-systems.de>
---
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..72bc4a42eac1 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->ingress_ifindex);
- if (idev && idev->netdev_ops == eth->netdev[0]->netdev_ops) {
+ if (idev && 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->ppe_num))
--
2.51.0
On Sat, Jan 03, 2026 at 01:50:08AM +0100, Sebastian Roland Wolf wrote:
> 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
> 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.
Hi Sebastian,
I agree that the cited hash is a good commit to reference, but
I think the Fixes line has been mangled. A correct tag for that hash is:
Fixes: 73cfd947dbdb ("net: ethernet: mtk_eth_soc: ppe: prevent ppe update for non-mtk devices")
Also, please no blank line here, between the Fixes line and your Signed-off by.
>
> Signed-off-by: Sebastian Roland Wolf <Sebastian.Wolf@pace-systems.de>
...
On Sat, Jan 03, 2026 at 01:50:08AM +0100, Sebastian Roland Wolf wrote:
> 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
> element can be NULL. Checking these pointers before access is
> mandatory to avoid segmentation faults and kernel oops.
Would it make sense to return EOPNOTSUPP, or maybe ENODEV? This does
seem like an error case.
Andrew
On 03/01/2026 08:30, Andrew Lunn wrote: > On Sat, Jan 03, 2026 at 01:50:08AM +0100, Sebastian Roland Wolf wrote: >> 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 >> element can be NULL. Checking these pointers before access is >> mandatory to avoid segmentation faults and kernel oops. > > Would it make sense to return EOPNOTSUPP, or maybe ENODEV? This does > seem like an error case. The if condition checks for single device only, while the code was added with introduction of multiple PPEs. I believe we have to check multiple devices from eth[], but the author may know better (CCed Elad Yifee) > > Andrew
© 2016 - 2026 Red Hat, Inc.