summaryrefslogtreecommitdiffstats
path: root/drivers/net/bonding/bond_main.c
diff options
context:
space:
mode:
authorJiri Bohac2014-02-26 18:20:13 +0100
committerDavid S. Miller2014-02-27 04:37:12 +0100
commit09a89c219baf0f116387efc928e325cf23630f20 (patch)
tree1f519bad2ed29d173f443dbad899b93731118324 /drivers/net/bonding/bond_main.c
parentbonding: fix a div error caused by the slave release path (diff)
downloadkernel-qcow2-linux-09a89c219baf0f116387efc928e325cf23630f20.tar.gz
kernel-qcow2-linux-09a89c219baf0f116387efc928e325cf23630f20.tar.xz
kernel-qcow2-linux-09a89c219baf0f116387efc928e325cf23630f20.zip
bonding: disallow enslaving a bond to itself
Enslaving a bond to itself leads to an endless loop and hangs the kernel. Signed-off-by: Jiri Bohac <jbohac@suse.cz> Tested-by: Ding Tianhong <dingtianhong@huawei.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.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index b47fa0421e01..e5628fc725c3 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1197,6 +1197,11 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
return -EBUSY;
}
+ if (bond_dev == slave_dev) {
+ pr_err("%s: cannot enslave bond to itself.\n", bond_dev->name);
+ return -EPERM;
+ }
+
/* vlan challenged mutual exclusion */
/* no need to lock since we're protected by rtnl_lock */
if (slave_dev->features & NETIF_F_VLAN_CHALLENGED) {