From: Nikolay Aleksandrov Date: Mon, 31 Aug 2015 17:44:19 +0000 (-0700) Subject: mpls: fix mpls_net_init memory leak X-Git-Tag: v4.14-rc1~4777^2~22 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6ea3c9d5b042edf14eac1e21af21c41f81f3491e;p=platform%2Fkernel%2Flinux-rpi.git mpls: fix mpls_net_init memory leak 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 Signed-off-by: David S. Miller --- diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c index 8c5707d..bb185a2 100644 --- a/net/mpls/af_mpls.c +++ b/net/mpls/af_mpls.c @@ -1177,8 +1177,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; }