diff options
author | WANG Cong <xiyou.wangcong@gmail.com> | 2014-07-25 22:25:10 (GMT) |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-07-29 18:43:50 (GMT) |
commit | 9c5ff24f963919965155cf0c4a2323b22a0c5c84 (patch) | |
tree | 8be53cca32ce634c291589f161684913f42432ac /net/8021q/vlan.c | |
parent | a317a2f19da7d0af1f068cf4d3ae80cdd73643b7 (diff) | |
download | linux-9c5ff24f963919965155cf0c4a2323b22a0c5c84.tar.xz |
vlan: fail early when creating netdev named config
Similarly, vlan will create /proc/net/vlan/<dev>, so when we
create dev with name "config", it will confict with
/proc/net/vlan/config.
Reported-by: Stephane Chazelas <stephane.chazelas@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/8021q/vlan.c')
-rw-r--r-- | net/8021q/vlan.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c index cba9c21..64c6bed 100644 --- a/net/8021q/vlan.c +++ b/net/8021q/vlan.c @@ -325,23 +325,24 @@ static void vlan_transfer_features(struct net_device *dev, netdev_update_features(vlandev); } -static void __vlan_device_event(struct net_device *dev, unsigned long event) +static int __vlan_device_event(struct net_device *dev, unsigned long event) { + int err = 0; + switch (event) { case NETDEV_CHANGENAME: vlan_proc_rem_dev(dev); - if (vlan_proc_add_dev(dev) < 0) - pr_warn("failed to change proc name for %s\n", - dev->name); + err = vlan_proc_add_dev(dev); break; case NETDEV_REGISTER: - if (vlan_proc_add_dev(dev) < 0) - pr_warn("failed to add proc entry for %s\n", dev->name); + err = vlan_proc_add_dev(dev); break; case NETDEV_UNREGISTER: vlan_proc_rem_dev(dev); break; } + + return err; } static int vlan_device_event(struct notifier_block *unused, unsigned long event, @@ -356,8 +357,12 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event, bool last = false; LIST_HEAD(list); - if (is_vlan_dev(dev)) - __vlan_device_event(dev, event); + if (is_vlan_dev(dev)) { + int err = __vlan_device_event(dev, event); + + if (err) + return notifier_from_errno(err); + } if ((event == NETDEV_UP) && (dev->features & NETIF_F_HW_VLAN_CTAG_FILTER)) { |