Subject: Re: [PATCH net] net: dsa: ocelot: call dsa_tag_8021q_unregister() under rtnl_lock() on driver remove

From: Simon Horman <[email-masked]>
Date: Sat, 5 Aug 2023 10:10:07 +0200

On Fri, Aug 04, 2023 at 02:10:45PM +0300, Vladimir Oltean wrote:
> On Thu, Aug 03, 2023 at 09:29:38PM +0200, Simon Horman wrote:
> > On Thu, Aug 03, 2023 at 04:42:53PM +0300, Vladimir Oltean wrote:
> > > diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c
> > > index fd7eb4a52918..9a3e5ec16972 100644
> > > --- a/drivers/net/dsa/ocelot/felix.c
> > > +++ b/drivers/net/dsa/ocelot/felix.c
> > > @@ -1619,8 +1619,10 @@ static void felix_teardown(struct dsa_switch *ds)
> > >  	struct felix *felix = ocelot_to_felix(ocelot);
> > >  	struct dsa_port *dp;
> > >  
> > > +	rtnl_lock();
> > >  	if (felix->tag_proto_ops)
> > >  		felix->tag_proto_ops->teardown(ds);
> > > +	rtnl_unlock();
> > 
> > Hi Vladimir,
> > 
> > I am curious to know if RTNL could be taken in
> > felix_tag_8021q_teardown() instead.
> 
> Negative. This call path also exists:
> 
> dsa_tree_change_tag_proto()
> -> rtnl_trylock()
> -> dsa_tree_notify(dst, DSA_NOTIFIER_TAG_PROTO, &info)
>    -> dsa_switch_change_tag_proto()
>       -> ds->ops->change_tag_protocol()
>          -> felix_change_tag_protocol()
>             -> old_proto_ops->teardown()
>                -> felix_tag_8021q_teardown()
> 
> where the rtnl_mutex is already held.

Ack. Thanks for confirming.
In that case this looks good to me.

Reviewed-by: Simon Horman <[email-masked]>