macvlan: do proper cleanup in macvlan_common_newlink() V2

Fixes possible memory leak.

Signed-off-by: Jiri Pirko <jpirko@redhat.com>
Acked-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Jiri Pirko 2010-05-24 07:02:25 +00:00 committed by David S. Miller
parent 556ae19110
commit f16d3d5748
1 changed files with 8 additions and 1 deletions

View File

@ -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);