Commit bc3f9076 authored by Wang Chen's avatar Wang Chen Committed by David S. Miller

bridge: Check return of dev_set_promiscuity

dev_set_promiscuity/allmulti might overflow.
Commit: "netdevice: Fix promiscuity and allmulti overflow" in net-next makes
dev_set_promiscuity/allmulti return error number if overflow happened.

Here, we check the positive increment for promiscuity to get error return.
Signed-off-by: default avatarWang Chen <wangchen@cn.fujitsu.com>
Signed-off-by: default avatarStephen Hemminger <shemminger@vyatta.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7e1a1ac1
...@@ -373,6 +373,10 @@ int br_add_if(struct net_bridge *br, struct net_device *dev) ...@@ -373,6 +373,10 @@ int br_add_if(struct net_bridge *br, struct net_device *dev)
if (IS_ERR(p)) if (IS_ERR(p))
return PTR_ERR(p); return PTR_ERR(p);
err = dev_set_promiscuity(dev, 1);
if (err)
goto put_back;
err = kobject_init_and_add(&p->kobj, &brport_ktype, &(dev->dev.kobj), err = kobject_init_and_add(&p->kobj, &brport_ktype, &(dev->dev.kobj),
SYSFS_BRIDGE_PORT_ATTR); SYSFS_BRIDGE_PORT_ATTR);
if (err) if (err)
...@@ -388,7 +392,6 @@ int br_add_if(struct net_bridge *br, struct net_device *dev) ...@@ -388,7 +392,6 @@ int br_add_if(struct net_bridge *br, struct net_device *dev)
rcu_assign_pointer(dev->br_port, p); rcu_assign_pointer(dev->br_port, p);
dev_disable_lro(dev); dev_disable_lro(dev);
dev_set_promiscuity(dev, 1);
list_add_rcu(&p->list, &br->port_list); list_add_rcu(&p->list, &br->port_list);
...@@ -412,12 +415,12 @@ int br_add_if(struct net_bridge *br, struct net_device *dev) ...@@ -412,12 +415,12 @@ int br_add_if(struct net_bridge *br, struct net_device *dev)
br_fdb_delete_by_port(br, p, 1); br_fdb_delete_by_port(br, p, 1);
err1: err1:
kobject_del(&p->kobj); kobject_del(&p->kobj);
goto put_back;
err0: err0:
kobject_put(&p->kobj); kobject_put(&p->kobj);
dev_set_promiscuity(dev, -1);
put_back: put_back:
dev_put(dev); dev_put(dev);
kfree(p);
return err; return err;
} }
......
Markdown is supported
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