Skip to contentSkip to conversation

memstick: r592: shut down the detect timer on removal

PATCH New Myeonghun Pak 1 participant 1 message Nov 10

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

PATCH 1/1 memstick: r592: shut down the detect timer on removal

r592_remove() deletes detect_timer before freeing the interrupt. A card insertion or removal interrupt can re-arm it in between, allowing r592_detect_timer() to access unmapped registers and queue media_checker work on the freed host.

Use timer_shutdown_sync() to wait for the callback and prevent re-arming. Keep timer_delete_sync() in r592_suspend(), since the timer is needed again after resume.

Found by a static analysis tool under development.

Fixes 632644227850 ("memstick: r592: Fix UAF bug in r592_remove due to race condition")

---

 drivers/memstick/host/r592.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/memstick/host/r592.c +1 -1
index dc3de63901be..399873a61d1b 100644
@@ -827,7 +827,7 @@ static void r592_remove(struct pci_dev *pdev)
 	/* Stop the processing thread.
 	That ensures that we won't take any more requests */
 	kthread_stop(dev->io_thread);
-	timer_delete_sync(&dev->detect_timer);
+	timer_shutdown_sync(&dev->detect_timer);
 	r592_enable_device(dev, false);
 
 	while (!error && dev->req) {

base-commit: 630059a5a632377b9b7b487baccde92b7ae1dd47

Signature · 1 line
2.43.0