summaryrefslogtreecommitdiffstats
path: root/net/x25/sysctl_net_x25.c
diff options
context:
space:
mode:
authorlinzhang <xiaolou4617@gmail.com>2017-05-17 06:05:07 +0200
committerDavid S. Miller <davem@davemloft.net>2017-05-18 16:05:40 +0200
commit64df6d525fcff1630098db9238bfd2b3e092d5c1 (patch)
tree891f6e66c98038bce663c67f96ef3b40b8aa00d4 /net/x25/sysctl_net_x25.c
parentbpf: adjust verifier heuristics (diff)
downloadlinux-64df6d525fcff1630098db9238bfd2b3e092d5c1.tar.xz
linux-64df6d525fcff1630098db9238bfd2b3e092d5c1.zip
net: x25: fix one potential use-after-free issue
The function x25_init is not properly unregister related resources on error handler.It is will result in kernel oops if x25_init init failed, so add properly unregister call on error handler. Also, i adjust the coding style and make x25_register_sysctl properly return failure. Signed-off-by: linzhang <xiaolou4617@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/x25/sysctl_net_x25.c')
-rw-r--r--net/x25/sysctl_net_x25.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/net/x25/sysctl_net_x25.c b/net/x25/sysctl_net_x25.c
index a06dfe143c67..ba078c85f0a1 100644
--- a/net/x25/sysctl_net_x25.c
+++ b/net/x25/sysctl_net_x25.c
@@ -73,9 +73,12 @@ static struct ctl_table x25_table[] = {
{ },
};
-void __init x25_register_sysctl(void)
+int __init x25_register_sysctl(void)
{
x25_table_header = register_net_sysctl(&init_net, "net/x25", x25_table);
+ if (!x25_table_header)
+ return -ENOMEM;
+ return 0;
}
void x25_unregister_sysctl(void)