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") Cc: stable@vger.kernel.org Co-developed-by: Ijae Kim Signed-off-by: Ijae Kim Signed-off-by: Myeonghun Pak --- drivers/memstick/host/r592.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/memstick/host/r592.c b/drivers/memstick/host/r592.c index dc3de63901be..399873a61d1b 100644 --- a/drivers/memstick/host/r592.c +++ b/drivers/memstick/host/r592.c @@ -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 -- 2.43.0