Skip to content

Commit

Permalink
mpls: fix mpls_net_init memory leak
Browse files Browse the repository at this point in the history
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: 7720c01 ("mpls: Add a sysctl to control the size of the mpls label table")
Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Nikolay Aleksandrov authored and davem330 committed Aug 31, 2015
1 parent f0fa6e5 commit 6ea3c9d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion net/mpls/af_mpls.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 6ea3c9d

Please sign in to comment.