From: Jiri Bohac Date: Wed, 26 Feb 2014 17:20:13 +0000 (+0100) Subject: bonding: disallow enslaving a bond to itself X-Git-Tag: v3.14-rc6~30^2~25 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=09a89c219baf0f116387efc928e325cf23630f20;p=profile%2Fcommon%2Fkernel-common.git 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 Tested-by: Ding Tianhong Signed-off-by: David S. Miller --- diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index b47fa04..e5628fc 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) {