Message ID | 49F04FD7.7080508@cosmosbay.com |
---|---|
State | Superseded, archived |
Delegated to: | David Miller |
Headers | show |
Thu, Apr 23, 2009 at 01:24:07PM CEST, dada1@cosmosbay.com wrote: >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> > >diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c >index 63369b6..66697db 100644 >--- a/drivers/net/bonding/bond_main.c >+++ b/drivers/net/bonding/bond_main.c >@@ -2213,33 +2213,27 @@ static int bond_slave_info_query(struct net_device *bond_dev, struct ifslave *in > { > struct bonding *bond = netdev_priv(bond_dev); > struct slave *slave; >- int i, found = 0; >+ int i, ret = -ENODEV; > >- if (info->slave_id < 0) { >+ if (info->slave_id < 0) > return -ENODEV; You can return ret; here since -ENODEV is there, but I don't know if it isn't against policy. Patch looks good anyway. >- } > > read_lock(&bond->lock); > > bond_for_each_slave(bond, slave, i) { > if (i == (int)info->slave_id) { >- found = 1; >+ ret = 0; >+ strcpy(info->slave_name, slave->dev->name); >+ info->link = slave->link; >+ info->state = slave->state; >+ info->link_failure_count = slave->link_failure_count; > break; > } > } > > read_unlock(&bond->lock); > >- if (found) { >- strcpy(info->slave_name, slave->dev->name); >- info->link = slave->link; >- info->state = slave->state; >- info->link_failure_count = slave->link_failure_count; >- } else { >- return -ENODEV; >- } >- >- return 0; >+ return ret; > } > > /*-------------------------------- Monitoring -------------------------------*/ >-- >To unsubscribe from this list: send the line "unsubscribe netdev" in >the body of a message to majordomo@vger.kernel.org >More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
From: Eric Dumazet <dada1@cosmosbay.com> Date: Thu, 23 Apr 2009 13:24:07 +0200 > 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> Applied, thanks Eric. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 63369b6..66697db 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -2213,33 +2213,27 @@ static int bond_slave_info_query(struct net_device *bond_dev, struct ifslave *in { struct bonding *bond = netdev_priv(bond_dev); struct slave *slave; - int i, found = 0; + int i, ret = -ENODEV; - if (info->slave_id < 0) { + if (info->slave_id < 0) return -ENODEV; - } read_lock(&bond->lock); bond_for_each_slave(bond, slave, i) { if (i == (int)info->slave_id) { - found = 1; + ret = 0; + strcpy(info->slave_name, slave->dev->name); + info->link = slave->link; + info->state = slave->state; + info->link_failure_count = slave->link_failure_count; break; } } read_unlock(&bond->lock); - if (found) { - strcpy(info->slave_name, slave->dev->name); - info->link = slave->link; - info->state = slave->state; - info->link_failure_count = slave->link_failure_count; - } else { - return -ENODEV; - } - - return 0; + return ret; } /*-------------------------------- Monitoring -------------------------------*/
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> -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html