Re: [PATCH net v4] net: dsa: mt7530: fix .get_stats64 sleeping in atomic context

Jakub Kicinski
2026-04-30T00:11:25Z

On Thu, 30 Apr 2026 00:55:01 +0100 Daniel Golle wrote:
> > > @@ -3409,6 +3476,9 @@ mt7530_remove_common(struct mt7530_priv *priv)
> > >
> > > dsa_unregister_switch(priv->ds);
> > >
> > > + if (priv->bus)
> > > + cancel_delayed_work_sync(&priv->stats_work);
> >
> > Could this call cancel_delayed_work_sync() on an uninitialized work struct
> > if the driver is unbound before the DSA switch tree completes?
> >
> > The priv->bus pointer is initialized during probe. However,
> > INIT_DELAYED_WORK() is only called in mt753x_setup(), which might never
> > execute if the DSA tree remains incomplete.
> >
> > If the driver is unbound in this state, mt7530_remove_common() will evaluate
> > priv->bus as true and pass a zero-initialized work struct to
> > cancel_delayed_work_sync(). This usually triggers lockdep ("trying to
> > register non-static key") and debugobjects ("assert_init not available")
> > warnings.
> >
> > Would it be better to move the INIT_DELAYED_WORK() call into the probe
> > path or track whether the setup function was actually completed?
>
> Not sure if this is real. The fix could be simply
>
> if (priv->bus && priv->ds->setup)
> cancel_delayed_work_sync(&priv->stats_work);
>
> Anyone?

Not sure how much of the D in DSA is actually implemented but in terms
of fix why not do what the bot suggests?