Skip to content

Commit

Permalink
macvlan: do proper cleanup in macvlan_common_newlink() V2
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jiri Pirko authored and David S. Miller committed May 25, 2010
1 parent 556ae19 commit f16d3d5
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion drivers/net/macvlan.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit f16d3d5

Please sign in to comment.