Re: [PATCH net] net: dsa: don't assign an error value to tag_ops

From: George McCollister
Date: Mon Mar 22 2021 - 16:52:18 EST


On Mon, Mar 22, 2021 at 3:46 PM Vladimir Oltean <olteanv@xxxxxxxxx> wrote:
>
> On Mon, Mar 22, 2021 at 03:26:50PM -0500, George McCollister wrote:
> > Use a temporary variable to hold the return value from
> > dsa_tag_driver_get() instead of assigning it to dst->tag_ops. Leaving
> > an error value in dst->tag_ops can result in deferencing an invalid
> > pointer when a deferred switch configuration happens later.
> >
> > Fixes: 357f203bb3b5 ("net: dsa: keep a copy of the tagging protocol in the DSA switch tree")
> >
> > Signed-off-by: George McCollister <george.mccollister@xxxxxxxxx>
> > ---
>
> Who dereferences the invalid pointer? dsa_tree_free I guess?

I saw it occur just above on the following line the next time
dsa_port_parse_cpu() is called:
if (dst->tag_ops->proto != tag_protocol) {

-George