Commit 11f3a6bd authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

bridge: fix a possible net_device leak

Jan Beulich reported a possible net_device leak in bridge code after
commit bb900b27 (bridge: allow creating bridge devices with netlink)
Reported-by: default avatarJan Beulich <JBeulich@novell.com>
Signed-off-by: default avatarEric Dumazet <eric.dumazet@gmail.com>
Acked-by: default avatarStephen Hemminger <shemminger@vyatta.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 832d80ac
...@@ -231,6 +231,7 @@ static struct net_bridge_port *new_nbp(struct net_bridge *br, ...@@ -231,6 +231,7 @@ static struct net_bridge_port *new_nbp(struct net_bridge *br,
int br_add_bridge(struct net *net, const char *name) int br_add_bridge(struct net *net, const char *name)
{ {
struct net_device *dev; struct net_device *dev;
int res;
dev = alloc_netdev(sizeof(struct net_bridge), name, dev = alloc_netdev(sizeof(struct net_bridge), name,
br_dev_setup); br_dev_setup);
...@@ -240,7 +241,10 @@ int br_add_bridge(struct net *net, const char *name) ...@@ -240,7 +241,10 @@ int br_add_bridge(struct net *net, const char *name)
dev_net_set(dev, net); dev_net_set(dev, net);
return register_netdev(dev); res = register_netdev(dev);
if (res)
free_netdev(dev);
return res;
} }
int br_del_bridge(struct net *net, const char *name) int br_del_bridge(struct net *net, const char *name)
......
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