* [PATCH net] net: ethernet: mtk_eth_soc: Reset prog ptr to NULL in case of error in mtk_xdp_setup()
@ 2026-02-27 15:52 Lorenzo Bianconi
2026-03-01 18:30 ` Simon Horman
2026-03-03 2:29 ` Jakub Kicinski
0 siblings, 2 replies; 4+ messages in thread
From: Lorenzo Bianconi @ 2026-02-27 15:52 UTC (permalink / raw)
To: Felix Fietkau, Sean Wang, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Matthias Brugger,
AngeloGioacchino Del Regno, Alexei Starovoitov, Daniel Borkmann,
Jesper Dangaard Brouer, John Fastabend, Stanislav Fomichev
Cc: Paolo Valerio, netdev, linux-arm-kernel, linux-mediatek, bpf,
Lorenzo Bianconi
Reset eBPF prog pointer to NULL if mtk_open routine in mtk_xdp_setup()
fails.
Fixes: 7c26c20da5d42 ("net: ethernet: mtk_eth_soc: add basic XDP support")
Suggested-by: Paolo Valerio <pvalerio@redhat.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
drivers/net/ethernet/mediatek/mtk_eth_soc.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index e5e2ffa9c542bfc88dc0d7553d0a6b2a169ec74b..e199f2e243d21f3545e8282ab821135e0962f5c3 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -3751,8 +3751,16 @@ static int mtk_xdp_setup(struct net_device *dev, struct bpf_prog *prog,
if (old_prog)
bpf_prog_put(old_prog);
- if (netif_running(dev) && need_update)
- return mtk_open(dev);
+ if (netif_running(dev) && need_update) {
+ int err;
+
+ err = mtk_open(dev);
+ if (err) {
+ rcu_assign_pointer(eth->prog, NULL);
+
+ return err;
+ }
+ }
return 0;
}
---
base-commit: fd6dad4e1ae296b67b87291256878a58dad36c93
change-id: 20260227-mtk-xdp-prog-ptr-fix-af59b9cce7ba
Best regards,
--
Lorenzo Bianconi <lorenzo@kernel.org>
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net] net: ethernet: mtk_eth_soc: Reset prog ptr to NULL in case of error in mtk_xdp_setup()
2026-02-27 15:52 [PATCH net] net: ethernet: mtk_eth_soc: Reset prog ptr to NULL in case of error in mtk_xdp_setup() Lorenzo Bianconi
@ 2026-03-01 18:30 ` Simon Horman
2026-03-03 2:29 ` Jakub Kicinski
1 sibling, 0 replies; 4+ messages in thread
From: Simon Horman @ 2026-03-01 18:30 UTC (permalink / raw)
To: Lorenzo Bianconi
Cc: Felix Fietkau, Sean Wang, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Matthias Brugger,
AngeloGioacchino Del Regno, Alexei Starovoitov, Daniel Borkmann,
Jesper Dangaard Brouer, John Fastabend, Stanislav Fomichev,
Paolo Valerio, netdev, linux-arm-kernel, linux-mediatek, bpf
On Fri, Feb 27, 2026 at 04:52:11PM +0100, Lorenzo Bianconi wrote:
> Reset eBPF prog pointer to NULL if mtk_open routine in mtk_xdp_setup()
> fails.
>
> Fixes: 7c26c20da5d42 ("net: ethernet: mtk_eth_soc: add basic XDP support")
> Suggested-by: Paolo Valerio <pvalerio@redhat.com>
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Reviewed-by: Simon Horman <horms@kernel.org>
...
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] net: ethernet: mtk_eth_soc: Reset prog ptr to NULL in case of error in mtk_xdp_setup()
2026-02-27 15:52 [PATCH net] net: ethernet: mtk_eth_soc: Reset prog ptr to NULL in case of error in mtk_xdp_setup() Lorenzo Bianconi
2026-03-01 18:30 ` Simon Horman
@ 2026-03-03 2:29 ` Jakub Kicinski
2026-03-03 9:25 ` Lorenzo Bianconi
1 sibling, 1 reply; 4+ messages in thread
From: Jakub Kicinski @ 2026-03-03 2:29 UTC (permalink / raw)
To: Lorenzo Bianconi
Cc: Felix Fietkau, Sean Wang, Andrew Lunn, David S. Miller,
Eric Dumazet, Paolo Abeni, Matthias Brugger,
AngeloGioacchino Del Regno, Alexei Starovoitov, Daniel Borkmann,
Jesper Dangaard Brouer, John Fastabend, Stanislav Fomichev,
Paolo Valerio, netdev, linux-arm-kernel, linux-mediatek, bpf
On Fri, 27 Feb 2026 16:52:11 +0100 Lorenzo Bianconi wrote:
> --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> @@ -3751,8 +3751,16 @@ static int mtk_xdp_setup(struct net_device *dev, struct bpf_prog *prog,
> if (old_prog)
> bpf_prog_put(old_prog);
>
> - if (netif_running(dev) && need_update)
> - return mtk_open(dev);
> + if (netif_running(dev) && need_update) {
> + int err;
> +
> + err = mtk_open(dev);
> + if (err) {
> + rcu_assign_pointer(eth->prog, NULL);
> +
> + return err;
> + }
> + }
>
> return 0;
Maybe there's something special here, not obvious without context,
but why are we setting eth->prog to NULL rather than old_prog?
At the very least the commit message needs to explain..
--
pw-bot: cr
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] net: ethernet: mtk_eth_soc: Reset prog ptr to NULL in case of error in mtk_xdp_setup()
2026-03-03 2:29 ` Jakub Kicinski
@ 2026-03-03 9:25 ` Lorenzo Bianconi
0 siblings, 0 replies; 4+ messages in thread
From: Lorenzo Bianconi @ 2026-03-03 9:25 UTC (permalink / raw)
To: Jakub Kicinski
Cc: Felix Fietkau, Sean Wang, Andrew Lunn, David S. Miller,
Eric Dumazet, Paolo Abeni, Matthias Brugger,
AngeloGioacchino Del Regno, Alexei Starovoitov, Daniel Borkmann,
Jesper Dangaard Brouer, John Fastabend, Stanislav Fomichev,
Paolo Valerio, netdev, linux-arm-kernel, linux-mediatek, bpf
[-- Attachment #1: Type: text/plain, Size: 1027 bytes --]
> On Fri, 27 Feb 2026 16:52:11 +0100 Lorenzo Bianconi wrote:
> > --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> > +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> > @@ -3751,8 +3751,16 @@ static int mtk_xdp_setup(struct net_device *dev, struct bpf_prog *prog,
> > if (old_prog)
> > bpf_prog_put(old_prog);
> >
> > - if (netif_running(dev) && need_update)
> > - return mtk_open(dev);
> > + if (netif_running(dev) && need_update) {
> > + int err;
> > +
> > + err = mtk_open(dev);
> > + if (err) {
> > + rcu_assign_pointer(eth->prog, NULL);
> > +
> > + return err;
> > + }
> > + }
> >
> > return 0;
>
> Maybe there's something special here, not obvious without context,
> but why are we setting eth->prog to NULL rather than old_prog?
> At the very least the commit message needs to explain..
Reviewing the code I agree, we can just restore the old program, moving
bpf_prog_put() below the error condition. I will fix it in v2.
Regards,
Lorenzo
> --
> pw-bot: cr
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-03-03 9:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-27 15:52 [PATCH net] net: ethernet: mtk_eth_soc: Reset prog ptr to NULL in case of error in mtk_xdp_setup() Lorenzo Bianconi
2026-03-01 18:30 ` Simon Horman
2026-03-03 2:29 ` Jakub Kicinski
2026-03-03 9:25 ` Lorenzo Bianconi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox