From: Miaohe Lin Date: Fri, 29 Apr 2022 06:16:18 +0000 (-0700) Subject: mm: compaction: avoid possible NULL pointer dereference in kcompactd_cpu_online X-Git-Tag: sched-urgent-2022-06-05~14^2~269 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=3109de308987ceae413ee015038d51e2a86c7806;p=users%2Fdwmw2%2Flinux.git mm: compaction: avoid possible NULL pointer dereference in kcompactd_cpu_online It's possible that kcompactd_run could fail to run kcompactd for a hot added node and leave pgdat->kcompactd as NULL. So pgdat->kcompactd should be checked here to avoid possible NULL pointer dereference. Link: https://lkml.kernel.org/r/20220418141253.24298-10-linmiaohe@huawei.com Signed-off-by: Miaohe Lin Cc: Charan Teja Kalla Cc: David Hildenbrand Cc: Pintu Kumar Cc: Vlastimil Babka Signed-off-by: Andrew Morton --- diff --git a/mm/compaction.c b/mm/compaction.c index 562f274b2c512..82c54d70a978c 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -3052,7 +3052,8 @@ static int kcompactd_cpu_online(unsigned int cpu) if (cpumask_any_and(cpu_online_mask, mask) < nr_cpu_ids) /* One of our CPUs online: restore mask */ - set_cpus_allowed_ptr(pgdat->kcompactd, mask); + if (pgdat->kcompactd) + set_cpus_allowed_ptr(pgdat->kcompactd, mask); } return 0; }