Skip to content

Commit 3ba359c

Browse files
jmberg-intelPaolo Abeni
authored andcommitted
net: bonding: correctly annotate RCU in bond_should_notify_peers()
RCU use in bond_should_notify_peers() looks wrong, since it does rcu_dereference(), leaves the critical section, and uses the pointer after that. Luckily, it's called either inside a nested RCU critical section or with the RTNL held. Annotate it with rcu_dereference_rtnl() instead, and remove the inner RCU critical section. Fixes: 4cb4f97 ("bonding: rebuild the lock use for bond_mii_monitor()") Reviewed-by: Jiri Pirko <[email protected]> Signed-off-by: Johannes Berg <[email protected]> Acked-by: Jay Vosburgh <[email protected]> Link: https://patch.msgid.link/20240719094119.35c62455087d.I68eb9c0f02545b364b79a59f2110f2cf5682a8e2@changeid Signed-off-by: Paolo Abeni <[email protected]>
1 parent 39a9c25 commit 3ba359c

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

drivers/net/bonding/bond_main.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,13 +1121,10 @@ static struct slave *bond_find_best_slave(struct bonding *bond)
11211121
return bestslave;
11221122
}
11231123

1124+
/* must be called in RCU critical section or with RTNL held */
11241125
static bool bond_should_notify_peers(struct bonding *bond)
11251126
{
1126-
struct slave *slave;
1127-
1128-
rcu_read_lock();
1129-
slave = rcu_dereference(bond->curr_active_slave);
1130-
rcu_read_unlock();
1127+
struct slave *slave = rcu_dereference_rtnl(bond->curr_active_slave);
11311128

11321129
if (!slave || !bond->send_peer_notif ||
11331130
bond->send_peer_notif %

0 commit comments

Comments
 (0)