[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211209064314.2074885-1-jiasheng@iscas.ac.cn>
Date: Thu, 9 Dec 2021 14:43:14 +0800
From: Jiasheng Jiang <jiasheng@...as.ac.cn>
To: akpm@...ux-foundation.org, pmladek@...e.com,
valentin.schneider@....com, peterz@...radead.org,
keescook@...omium.org, robdclark@...omium.org,
samitolvanen@...gle.com
Cc: linux-kernel@...r.kernel.org, Jiasheng Jiang <jiasheng@...as.ac.cn>
Subject: [PATCH] kthread: potential dereference of null pointer
The return value of kzalloc() needs to be checked.
To avoid use of null pointer in case of the failure of alloc.
Fixes: dc6a87f5450d ("sched: Make the idle task quack like a per-CPU kthread")
Signed-off-by: Jiasheng Jiang <jiasheng@...as.ac.cn>
---
kernel/kthread.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/kernel/kthread.c b/kernel/kthread.c
index 08931e525dd9..3feefeff4922 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -101,6 +101,8 @@ void set_kthread_struct(struct task_struct *p)
return;
kthread = kzalloc(sizeof(*kthread), GFP_KERNEL);
+ if (!kthread)
+ return;
/*
* We abuse ->set_child_tid to avoid the new member and because it
* can't be wrongly copied by copy_process(). We also rely on fact
--
2.25.1
Powered by blists - more mailing lists