Patchwork [net-2.6] macvlan: do a proper cleanup in macvlan_common_newlink()

login
register
mail settings
Submitter Jiri Pirko
Date May 24, 2010, 3:58 p.m.
Message ID <20100524155857.GO2810@psychotron.lab.eng.brq.redhat.com>
Download mbox | patch
Permalink /patch/53434/
State Superseded
Delegated to: David Miller
Headers show

Comments

Jiri Pirko - May 24, 2010, 3:58 p.m.
Fixes possible memory leak.

Signed-off-by: Jiri Pirko <jpirko@redhat.com>
---
 drivers/net/macvlan.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

Patch

diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index 4e238af..5f4694b 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -634,11 +634,17 @@  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:
+	macvlan_port_destroy(lowerdev);
+
+	return err;
 }
 EXPORT_SYMBOL_GPL(macvlan_common_newlink);