From: Jiri Pirko Date: Mon, 24 May 2010 07:02:25 +0000 (+0000) Subject: macvlan: do proper cleanup in macvlan_common_newlink() V2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=f16d3d57486cd079b29ae7a6c3b31c90e69c9c44;p=GitHub%2Fexynos8895%2Fandroid_kernel_samsung_universal8895.git macvlan: do proper cleanup in macvlan_common_newlink() V2 Fixes possible memory leak. Signed-off-by: Jiri Pirko Acked-by: Patrick McHardy Signed-off-by: David S. Miller --- diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c index 4e238afab4a3..87e8d4cb4057 100644 --- a/drivers/net/macvlan.c +++ b/drivers/net/macvlan.c @@ -634,11 +634,18 @@ int macvlan_common_newlink(struct net *src_net, struct net_device *dev, err = register_netdevice(dev); if (err < 0) - return err; + goto destroy_port; list_add_tail(&vlan->list, &port->vlans); netif_stacked_transfer_operstate(lowerdev, dev); + return 0; + +destroy_port: + if (list_empty(&port->vlans)) + macvlan_port_destroy(lowerdev); + + return err; } EXPORT_SYMBOL_GPL(macvlan_common_newlink);