Messages in this thread Patch in this message | | | From | Jiasheng Jiang <> | Subject | [PATCH] kthread: potential dereference of null pointer | Date | Thu, 9 Dec 2021 14:43:14 +0800 |
| |
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@iscas.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
| |