[PATCH 08/13] mmc: omap: Shut down cover timer before disabling cover BH work
From: Lee Jones
Date: Mon Nov 23 2026 - 14:18:26 EST
In mmc_omap_remove_slot(), cancel_work_sync(&slot->cover_bh_work) is
called before timer_delete_sync(&slot->cover_timer). Because
mmc_omap_cover_timer() queues slot->cover_bh_work and
mmc_omap_cover_bh_handler() rearms slot->cover_timer, a timer expiry
between the two calls (or a concurrent omap_mmc_notify_cover_event()
before platform cleanup) can re-queue cover_bh_work so that it runs
after the slot and its struct mmc_host have been freed.
When cover state polling is configured, shut down slot->cover_timer
first with timer_shutdown_sync() to prevent re-arming, and then stop
slot->cover_bh_work with disable_work_sync() so no further work can be
queued during teardown.
Fixes: 7584d276d47a ("MMC: OMAP: Use tasklet instead of workqueue for cover switch notification")
Fixes: 921c87ba3893 ("mmc: Convert from tasklet to BH workqueue")
Closes: https://sashiko.dev/#/bug/linux-f30b1077-ed4d-4d62-a07b-11fff78d42c5
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Lee Jones <lee@xxxxxxxxxx>
---
drivers/mmc/host/omap.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/mmc/host/omap.c b/drivers/mmc/host/omap.c
index 36df578298c3..55efc4ec9d03 100644
--- a/drivers/mmc/host/omap.c
+++ b/drivers/mmc/host/omap.c
@@ -1356,11 +1356,11 @@ static void mmc_omap_remove_slot(struct mmc_omap_slot *slot)
if (slot->pdata->name != NULL)
device_remove_file(&mmc->class_dev, &dev_attr_slot_name);
- if (slot->pdata->get_cover_state != NULL)
+ if (slot->pdata->get_cover_state) {
device_remove_file(&mmc->class_dev, &dev_attr_cover_switch);
-
- cancel_work_sync(&slot->cover_bh_work);
- timer_delete_sync(&slot->cover_timer);
+ timer_shutdown_sync(&slot->cover_timer);
+ disable_work_sync(&slot->cover_bh_work);
+ }
flush_workqueue(slot->host->mmc_omap_wq);
mmc_remove_host(mmc);
--
2.56.1.750.gf70dc682cf-goog