diff options
author | Eric Dumazet <dada1@cosmosbay.com> | 2009-04-22 23:39:04 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-05-01 18:18:19 -0400 |
commit | 689c96cca7ec3d2ba7fba00481810f99f1803c63 (patch) | |
tree | 0aede65eabbcbcb8bb0eaebca225a56772e5a8eb /drivers/net/bonding/bond_main.c | |
parent | 00b64f2aa5e8741b49e48ebad1116cc78dbbf0fd (diff) |
bonding: bond_slave_info_query() fix
bond_slave_info_query() should keep a read lock while accessing slave info,
or risk accessing stale data and corruption.
Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
Signed-off-by: Jay Vosburgh <fubar@us.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bonding/bond_main.c')
-rw-r--r-- | drivers/net/bonding/bond_main.c | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 63369b6b14d..67515b78ff9 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c | |||
@@ -2213,33 +2213,24 @@ static int bond_slave_info_query(struct net_device *bond_dev, struct ifslave *in | |||
2213 | { | 2213 | { |
2214 | struct bonding *bond = netdev_priv(bond_dev); | 2214 | struct bonding *bond = netdev_priv(bond_dev); |
2215 | struct slave *slave; | 2215 | struct slave *slave; |
2216 | int i, found = 0; | 2216 | int i, res = -ENODEV; |
2217 | |||
2218 | if (info->slave_id < 0) { | ||
2219 | return -ENODEV; | ||
2220 | } | ||
2221 | 2217 | ||
2222 | read_lock(&bond->lock); | 2218 | read_lock(&bond->lock); |
2223 | 2219 | ||
2224 | bond_for_each_slave(bond, slave, i) { | 2220 | bond_for_each_slave(bond, slave, i) { |
2225 | if (i == (int)info->slave_id) { | 2221 | if (i == (int)info->slave_id) { |
2226 | found = 1; | 2222 | res = 0; |
2223 | strcpy(info->slave_name, slave->dev->name); | ||
2224 | info->link = slave->link; | ||
2225 | info->state = slave->state; | ||
2226 | info->link_failure_count = slave->link_failure_count; | ||
2227 | break; | 2227 | break; |
2228 | } | 2228 | } |
2229 | } | 2229 | } |
2230 | 2230 | ||
2231 | read_unlock(&bond->lock); | 2231 | read_unlock(&bond->lock); |
2232 | 2232 | ||
2233 | if (found) { | 2233 | return res; |
2234 | strcpy(info->slave_name, slave->dev->name); | ||
2235 | info->link = slave->link; | ||
2236 | info->state = slave->state; | ||
2237 | info->link_failure_count = slave->link_failure_count; | ||
2238 | } else { | ||
2239 | return -ENODEV; | ||
2240 | } | ||
2241 | |||
2242 | return 0; | ||
2243 | } | 2234 | } |
2244 | 2235 | ||
2245 | /*-------------------------------- Monitoring -------------------------------*/ | 2236 | /*-------------------------------- Monitoring -------------------------------*/ |