Message ID | 1314029159.2307.99.camel@edumazet-HP-Compaq-6005-Pro-SFF-PC |
---|---|
State | Accepted, archived |
Delegated to: | David Miller |
Headers | show |
From: Eric Dumazet <eric.dumazet@gmail.com> Date: Mon, 22 Aug 2011 18:05:59 +0200 > [PATCH] bridge: fix a possible net_device leak > > Jan Beulich reported a possible net_device leak in bridge code after > commit bb900b27a2f4 (bridge: allow creating bridge devices with netlink) > > Reported-by: Jan Beulich <JBeulich@novell.com> > Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> > Acked-by: Stephen Hemminger <shemminger@vyatta.com> Applied, thanks Eric. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c index 2cdf007..e738154 100644 --- a/net/bridge/br_if.c +++ b/net/bridge/br_if.c @@ -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) { struct net_device *dev; + int res; dev = alloc_netdev(sizeof(struct net_bridge), name, br_dev_setup); @@ -240,7 +241,10 @@ int br_add_bridge(struct net *net, const char *name) 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)