Skip to contentSkip to conversation

bus: mhi: host: Shut down the health check timer on removal

PATCH In review Myeonghun Pak 2 participants 2 messages Oct 11 – Oct 30

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bus: mhi: host: Shut down the health check timer on removal

The recovery worker rearms health_check_timer after a successful device recovery. Deleting the timer before cancel_work_sync() does not prevent an already running recovery worker from adding it again while removal waits for that worker. The timer can then run after the controller and the managed mhi_pci_device have been released.

Use timer_shutdown_sync() before cancelling recovery_work. This waits for the timer callback and rejects subsequent rearming, including rearming by the worker being cancelled. Keep the reversible timer deletion used by suspend and reset paths.

This issue was found by static analysis.

Fixes 8562d4fe34a3 ("mhi: pci_generic: Add health-check")
Assisted-by LLM

---
Compile-tested with GCC, W=1 (arm). No runtime testing.

 drivers/bus/mhi/host/pci_generic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/bus/mhi/host/pci_generic.c +1 -1
index b636e2c..f8de889 100644
@@ -1488,7 +1488,7 @@ static void mhi_pci_remove(struct pci_dev *pdev)
 	pci_disable_sriov(pdev);
 
 	if (!pdev->is_virtfn)
-		timer_delete_sync(&mhi_pdev->health_check_timer);
+		timer_shutdown_sync(&mhi_pdev->health_check_timer);
 	cancel_work_sync(&mhi_pdev->recovery_work);
 
 	if (test_and_clear_bit(MHI_PCI_DEV_STARTED, &mhi_pdev->status)) {
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Myeonghun Pak

The recovery worker rearms health_check_timer after a successful device recovery. Deleting the timer before cancel_work_sync() does not prevent an already running recovery worker from adding it again while removal waits for that worker. The timer can then run after the controller and the managed mhi_pci_device have been released.

Use timer_shutdown_sync() before cancelling recovery_work. This waits for the timer callback and rejects subsequent rearming, including rearming by the worker being cancelled. Keep the reversible timer deletion used by suspend and reset paths.

Quoted 7 lines

This issue was found by static analysis.

Fixes 8562d4fe34a3 ("mhi: pci_generic: Add health-check")
Assisted-by LLM