diff options
author | dingtianhong <dingtianhong@huawei.com> | 2013-07-23 15:25:39 +0800 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-07-24 17:45:23 -0700 |
commit | 9402b746e7ba0f317ffa465a4c5128c7c220f27b (patch) | |
tree | 81801c39a71e208ea61861b753b4cc5ef3883b82 /drivers/net/bonding/bond_sysfs.c | |
parent | 38c4916a7874aff9dc07a68bf8e7e4136b00f8dd (diff) |
bonding: add rtnl protection for bonding_store_fail_over_mac
We need rtnl protection while reading slave_cnt and updating
the .fail_over_mac, and it also follows the logic "don't change
anything slave-related without rtnl". :)
Signed-off-by: Ding Tianhong <dingtianhong@huawei.com>
Cc: Jay Vosburgh <fubar@us.ibm.com>
Cc: Andy Gospodarek <andy@greyhouse.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bonding/bond_sysfs.c')
-rw-r--r-- | drivers/net/bonding/bond_sysfs.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c index 984ca02cfe7..ae02c194c01 100644 --- a/drivers/net/bonding/bond_sysfs.c +++ b/drivers/net/bonding/bond_sysfs.c @@ -501,20 +501,25 @@ static ssize_t bonding_store_fail_over_mac(struct device *d, struct device_attribute *attr, const char *buf, size_t count) { - int new_value; + int new_value, ret = count; struct bonding *bond = to_bond(d); + if (!rtnl_trylock()) + return restart_syscall(); + if (bond->slave_cnt != 0) { pr_err("%s: Can't alter fail_over_mac with slaves in bond.\n", bond->dev->name); - return -EPERM; + ret = -EPERM; + goto out; } new_value = bond_parse_parm(buf, fail_over_mac_tbl); if (new_value < 0) { pr_err("%s: Ignoring invalid fail_over_mac value %s.\n", bond->dev->name, buf); - return -EINVAL; + ret = -EINVAL; + goto out; } bond->params.fail_over_mac = new_value; @@ -522,7 +527,9 @@ static ssize_t bonding_store_fail_over_mac(struct device *d, bond->dev->name, fail_over_mac_tbl[new_value].modename, new_value); - return count; +out: + rtnl_unlock(); + return ret; } static DEVICE_ATTR(fail_over_mac, S_IRUGO | S_IWUSR, |