mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 06:44:00 -04:00
bonding: convert primary_slave to use RCU
This is necessary mainly for two bonding call sites: procfs and sysfs as it was dereferenced without any real protection. Signed-off-by: Nikolay Aleksandrov <nikolay@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
ecfede424e
commit
059b47e8aa
@@ -425,11 +425,15 @@ static ssize_t bonding_show_primary(struct device *d,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
int count = 0;
|
||||
struct bonding *bond = to_bond(d);
|
||||
struct slave *primary;
|
||||
int count = 0;
|
||||
|
||||
if (bond->primary_slave)
|
||||
count = sprintf(buf, "%s\n", bond->primary_slave->dev->name);
|
||||
rcu_read_lock();
|
||||
primary = rcu_dereference(bond->primary_slave);
|
||||
if (primary)
|
||||
count = sprintf(buf, "%s\n", primary->dev->name);
|
||||
rcu_read_unlock();
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user