[PATCH] init/main.c: check for null pointer before calling initcall

From: Abderrahmane Benbachir
Date: Fri Oct 27 2017 - 12:59:37 EST


Simple check to prevent kernel panic when initcall does not exit

Signed-off-by: Abderrahmane Benbachir <abderrahmane.benbachir@xxxxxxxxxx>
---
init/main.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/init/main.c b/init/main.c
index 0ee9c6866ada..220fd2822b61 100644
--- a/init/main.c
+++ b/init/main.c
@@ -817,6 +817,9 @@ int __init_or_module do_one_initcall(initcall_t fn)
int ret;
char msgbuf[64];

+ if (unlikely(!fn))
+ return -EFAULT;
+
if (initcall_blacklisted(fn))
return -EPERM;

--
2.11.0