netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] mpls: fix mpls_net_init memory leak
@ 2015-08-31 17:44 Nikolay Aleksandrov
  2015-08-31 19:45 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Nikolay Aleksandrov @ 2015-08-31 17:44 UTC (permalink / raw)
  To: netdev; +Cc: ebiederm, roopa, davem, Nikolay Aleksandrov

From: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>

Fix a memory leak in the mpls netns init function in case of failure. If
register_net_sysctl fails then we need to free the ctl_table.

Fixes: 7720c01f3f59 ("mpls: Add a sysctl to control the size of the mpls label table")
Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
---
 net/mpls/af_mpls.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c
index 1f93a5978f2a..b1faa2dc0e6a 100644
--- a/net/mpls/af_mpls.c
+++ b/net/mpls/af_mpls.c
@@ -1066,8 +1066,10 @@ static int mpls_net_init(struct net *net)
 
 	table[0].data = net;
 	net->mpls.ctl = register_net_sysctl(net, "net/mpls", table);
-	if (net->mpls.ctl == NULL)
+	if (net->mpls.ctl == NULL) {
+		kfree(table);
 		return -ENOMEM;
+	}
 
 	return 0;
 }
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net] mpls: fix mpls_net_init memory leak
  2015-08-31 17:44 [PATCH net] mpls: fix mpls_net_init memory leak Nikolay Aleksandrov
@ 2015-08-31 19:45 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2015-08-31 19:45 UTC (permalink / raw)
  To: razor; +Cc: netdev, ebiederm, roopa, nikolay

From: Nikolay Aleksandrov <razor@blackwall.org>
Date: Mon, 31 Aug 2015 10:44:19 -0700

> From: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
> 
> Fix a memory leak in the mpls netns init function in case of failure. If
> register_net_sysctl fails then we need to free the ctl_table.
> 
> Fixes: 7720c01f3f59 ("mpls: Add a sysctl to control the size of the mpls label table")
> Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>

Applied, thank you.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-08-31 19:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-31 17:44 [PATCH net] mpls: fix mpls_net_init memory leak Nikolay Aleksandrov
2015-08-31 19:45 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).