]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
firmware: stratix10-svc: fix teardown order in remove to prevent race
authorAdrian Ng Ho Yin <adrian.ho.yin.ng@altera.com>
Tue, 14 Jul 2026 05:37:47 +0000 (13:37 +0800)
committerDinh Nguyen <dinguyen@kernel.org>
Tue, 14 Jul 2026 21:36:28 +0000 (16:36 -0500)
In stratix10_svc_drv_remove(), stratix10_svc_async_exit() was called
before client devices were unregistered. This created a race window
where child devices could still be issuing service requests through
the async channels after the async infrastructure had already been
torn down.

Unregister client devices before tearing down the async threads and
channels to ensure all in-flight service calls drain before the
underlying infrastructure is destroyed.

Fixes: bcb9f4f07061 ("firmware: stratix10-svc: Add support for async communication")
Cc: stable@vger.kernel.org
Signed-off-by: Adrian Ng Ho Yin <adrian.ho.yin.ng@altera.com>
Signed-off-by: Dinh Nguyen <dinguyen@kernel.org>
drivers/firmware/stratix10-svc.c

index c346f5fd397f3aad0097157dd6d17b5741508059..5e20057ee3446a6b8b74b3b0cc87750708650a49 100644 (file)
@@ -2049,12 +2049,12 @@ static void stratix10_svc_drv_remove(struct platform_device *pdev)
        struct stratix10_svc_controller *ctrl = platform_get_drvdata(pdev);
        struct stratix10_svc *svc = ctrl->svc;
 
+       platform_device_unregister(svc->stratix10_svc_rsu);
+
        stratix10_svc_async_exit(ctrl);
 
        of_platform_depopulate(ctrl->dev);
 
-       platform_device_unregister(svc->stratix10_svc_rsu);
-
        for (i = 0; i < SVC_NUM_CHANNEL; i++) {
                if (ctrl->chans[i].task) {
                        kthread_stop(ctrl->chans[i].task);