Commit 9402b746 authored by dingtianhong's avatar dingtianhong Committed by David S. Miller
Browse files

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: default avatarDing Tianhong <>
Cc: Jay Vosburgh <>
Cc: Andy Gospodarek <>
Signed-off-by: default avatarDavid S. Miller <>
parent 38c4916a
......@@ -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",
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,
return count;
return ret;
static DEVICE_ATTR(fail_over_mac, S_IRUGO | S_IWUSR,
Supports Markdown
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