[PATCH net] net: ethernet: mtk_eth_soc: Reset prog ptr to NULL in case of error in mtk_xdp_setup()

Lorenzo Bianconi lorenzo at kernel.org
Tue Mar 3 01:25:46 PST 2026


> 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-mediatek/attachments/20260303/9cab397d/attachment.sig>


More information about the Linux-mediatek mailing list