On Tue, Apr 12, 2022 at 21:36, Nikolay Aleksandrov <razor@xxxxxxxxxxxxx> wrote: > On 11/04/2022 16:38, Joachim Wiberg wrote: >> The br_setlink() function extracts the struct net_bridge pointer a bit >> sloppy. It's easy to interpret the code wrong. This patch attempts to >> clear things up a bit. > I think you can make it more straight-forward, remove the first br = netdev_priv > and do something like (completely untested): > ... > struct net_bridge_port *p = NULL; > ... > if (netif_is_bridge_master(dev)) { > br = netdev_priv(dev); > } else { > p = br_port_get_rtnl(dev); > if (WARN_ON(!p)) > return -EINVAL; > br = p->br; > } > > So br is always and only set in this block. Yes, this is much better, thank you! I took the misguided approach of minmizing my change. I'll update and include in the non-RFC patch series I send next.