Skip to contentSkip to conversation

smpboot: Add NULL check before kthread_unpark()

PATCH In review Kaushlendra Kumar 2 participants 4 messages Nov 24, 2025 – Dec 12, 2025 CPU hotplug

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 smpboot: Add NULL check before kthread_unpark()

Add NULL check for tsk before calling kthread_unpark() in smpboot_unpark_thread() to prevent potential null pointer dereference.

---
 kernel/smpboot.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/smpboot.c +1 -1
index 4503b60ce9bd..a37d25b23f58 100644
@@ -225,7 +225,7 @@ static void smpboot_unpark_thread(struct smp_hotplug_thread *ht, unsigned int cp
 {
 	struct task_struct *tsk = *per_cpu_ptr(ht->store, cpu);
 
-	if (!ht->selfparking)
+	if (tsk && !ht->selfparking)
 		kthread_unpark(tsk);
 }
 
Signature · 1 line
2.34.1
#1 lore raw
Quoted 3 lines · Kaushlendra Kumar

Add NULL check for tsk before calling kthread_unpark() in smpboot_unpark_thread() to prevent potential null pointer dereference.

How is that ever going to be NULL?

Thanks,

tglx

#2 lore raw
Quoted 5 lines · Thomas Gleixner
Quoted 2 lines · Kaushlendra Kumar

Add NULL check for tsk before calling kthread_unpark() in smpboot_unpark_thread() to prevent potential null pointer dereference.

How is that ever going to be NULL?

Thanks for the review.
Here I was only concerned about edge cases during CPU hotplug state transitions.

Could you help clarify: are there any scenarios during the CPU hotplug state transition where this function might be called without a valid task, or is the current flow guaranteed to always have tsk initialized at this point?

If the existing code ensure tsk is always valid here, will drop this patch.

-Kaushlendra

#3 lore raw
Quoted 8 lines · Kaushlendra Kumar
Quoted 5 lines · Thomas Gleixner
Quoted 2 lines · Kaushlendra Kumar

Add NULL check for tsk before calling kthread_unpark() in smpboot_unpark_thread() to prevent potential null pointer dereference.

How is that ever going to be NULL?

Thanks for the review.
Here I was only concerned about edge cases during CPU hotplug state transitions.

Then describe your concern and the edge cases in detail.

Thanks,

tglx