[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220411133837.318876-4-troglobit@gmail.com>
Date: Mon, 11 Apr 2022 15:38:27 +0200
From: Joachim Wiberg <troglobit@...il.com>
To: Roopa Prabhu <roopa@...dia.com>,
Nikolay Aleksandrov <razor@...ckwall.org>
Cc: netdev@...r.kernel.org, bridge@...ts.linux-foundation.org,
"David S . Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
Joachim Wiberg <troglobit@...il.com>,
Tobias Waldekranz <tobias@...dekranz.com>,
Vladimir Oltean <vladimir.oltean@....com>
Subject: [PATCH RFC net-next 03/13] net: bridge: minor refactor of br_setlink() for readability
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.
Signed-off-by: Joachim Wiberg <troglobit@...il.com>
---
net/bridge/br_netlink.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
index 7fca8ff13ec7..8f4297287b32 100644
--- a/net/bridge/br_netlink.c
+++ b/net/bridge/br_netlink.c
@@ -1040,6 +1040,8 @@ int br_setlink(struct net_device *dev, struct nlmsghdr *nlh, u16 flags,
return 0;
p = br_port_get_rtnl(dev);
+ if (p)
+ br = p->br;
/* We want to accept dev as bridge itself if the AF_SPEC
* is set to see if someone is setting vlan info on the bridge
*/
@@ -1055,17 +1057,17 @@ int br_setlink(struct net_device *dev, struct nlmsghdr *nlh, u16 flags,
if (err)
return err;
- spin_lock_bh(&p->br->lock);
+ spin_lock_bh(&br->lock);
err = br_setport(p, tb, extack);
- spin_unlock_bh(&p->br->lock);
+ spin_unlock_bh(&br->lock);
} else {
/* Binary compatibility with old RSTP */
if (nla_len(protinfo) < sizeof(u8))
return -EINVAL;
- spin_lock_bh(&p->br->lock);
+ spin_lock_bh(&br->lock);
err = br_set_port_state(p, nla_get_u8(protinfo));
- spin_unlock_bh(&p->br->lock);
+ spin_unlock_bh(&br->lock);
}
if (err)
goto out;
--
2.25.1
Powered by blists - more mailing lists