Commit 3ba359c0 authored by Johannes Berg's avatar Johannes Berg Committed by Paolo Abeni

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: 4cb4f97b ("bonding: rebuild the lock use for bond_mii_monitor()")
Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
Acked-by: default avatarJay Vosburgh <jv@jvosburgh.net>
Link: https://patch.msgid.link/20240719094119.35c62455087d.I68eb9c0f02545b364b79a59f2110f2cf5682a8e2@changeidSigned-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent 39a9c25b
...@@ -1121,13 +1121,10 @@ static struct slave *bond_find_best_slave(struct bonding *bond) ...@@ -1121,13 +1121,10 @@ static struct slave *bond_find_best_slave(struct bonding *bond)
return bestslave; return bestslave;
} }
/* must be called in RCU critical section or with RTNL held */
static bool bond_should_notify_peers(struct bonding *bond) static bool bond_should_notify_peers(struct bonding *bond)
{ {
struct slave *slave; struct slave *slave = rcu_dereference_rtnl(bond->curr_active_slave);
rcu_read_lock();
slave = rcu_dereference(bond->curr_active_slave);
rcu_read_unlock();
if (!slave || !bond->send_peer_notif || if (!slave || !bond->send_peer_notif ||
bond->send_peer_notif % bond->send_peer_notif %
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment