Commit f16d3d57 authored by Jiri Pirko's avatar Jiri Pirko Committed by David S. Miller

macvlan: do proper cleanup in macvlan_common_newlink() V2

Fixes possible memory leak.
Signed-off-by: default avatarJiri Pirko <jpirko@redhat.com>
Acked-by: default avatarPatrick McHardy <kaber@trash.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 556ae191
...@@ -634,11 +634,18 @@ int macvlan_common_newlink(struct net *src_net, struct net_device *dev, ...@@ -634,11 +634,18 @@ int macvlan_common_newlink(struct net *src_net, struct net_device *dev,
err = register_netdevice(dev); err = register_netdevice(dev);
if (err < 0) if (err < 0)
return err; goto destroy_port;
list_add_tail(&vlan->list, &port->vlans); list_add_tail(&vlan->list, &port->vlans);
netif_stacked_transfer_operstate(lowerdev, dev); netif_stacked_transfer_operstate(lowerdev, dev);
return 0; return 0;
destroy_port:
if (list_empty(&port->vlans))
macvlan_port_destroy(lowerdev);
return err;
} }
EXPORT_SYMBOL_GPL(macvlan_common_newlink); EXPORT_SYMBOL_GPL(macvlan_common_newlink);
......
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