]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
staging: vchiq_arm: Fix possible NPR of keep-alive thread
authorStefan Wahren <wahrenst@gmx.net>
Sun, 9 Mar 2025 12:50:11 +0000 (13:50 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 20 Mar 2025 14:11:20 +0000 (07:11 -0700)
In case vchiq_platform_conn_state_changed() is never called or fails before
driver removal, ka_thread won't be a valid pointer to a task_struct. So
do the necessary checks before calling kthread_stop to avoid a crash.

Fixes: 863a756aaf49 ("staging: vc04_services: vchiq_core: Stop kthreads on vchiq module unload")
Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
Link: https://lore.kernel.org/r/20250309125014.37166-3-wahrenst@gmx.net
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c

index 31bdb15fd75176ebc550c2bdce6d4120143b1ecc..910b8fd34cb1a8084bfb0a58f81c98e0d4b42967 100644 (file)
@@ -1422,7 +1422,8 @@ static void vchiq_remove(struct platform_device *pdev)
        kthread_stop(mgmt->state.slot_handler_thread);
 
        arm_state = vchiq_platform_get_arm_state(&mgmt->state);
-       kthread_stop(arm_state->ka_thread);
+       if (!IS_ERR_OR_NULL(arm_state->ka_thread))
+               kthread_stop(arm_state->ka_thread);
 }
 
 static struct platform_driver vchiq_driver = {