From: Tristan Madani ppa_detach() frees the ppa_struct without cancelling the pending delayed work ppa_tq. If ppa_interrupt() is still scheduled or running when the struct is freed, the work function accesses freed memory via container_of(). Add cancel_delayed_work_sync() after scsi_remove_host() has drained all in-flight commands and before the struct is freed. The cancel is placed after host removal so that ppa_interrupt() can still poll in-flight commands to completion during the drain, and no new commands can be queued after scsi_remove_host() returns. Fixes: c4028958b6eca ("WorkStruct: make allyesconfig") Cc: stable@vger.kernel.org Signed-off-by: Tristan Madani --- Changes in v2: - Moved cancel_delayed_work_sync() after scsi_remove_host() so that ppa_interrupt() can still poll in-flight commands to completion during the host drain. In v1 the cancel was placed before list_del_init() which could stall scsi_remove_host() by killing the polling mechanism for in-flight commands. drivers/scsi/ppa.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/scsi/ppa.c b/drivers/scsi/ppa.c index 8a4e910d5758f..d4fc8eedc29ce 100644 --- a/drivers/scsi/ppa.c +++ b/drivers/scsi/ppa.c @@ -1139,6 +1139,7 @@ static void ppa_detach(struct parport *pb) list_del_init(&dev->list); scsi_remove_host(dev->host); scsi_host_put(dev->host); + cancel_delayed_work_sync(&dev->ppa_tq); parport_unregister_device(dev->dev); kfree(dev); break; -- 2.47.3