[Devel] [PATCH hci-8.1 v3 1/9] drivers/md/dm-qcow2: cancel the event work and ENOSPC timer in the destructor

Alexander Ivanov alexander.ivanov at virtuozzo.com
Tue Nov 17 13:43:21 MSK 2026


qcow2_try_delay_enospc() schedules tgt->event_work on the system
workqueue and arms tgt->enospc_timer, but qcow2_tgt_destroy() frees
the target without waiting for either. A work item queued just
before the device is suspended and removed runs on freed memory.

https://virtuozzo.atlassian.net/browse/VSTOR-152175

Fixes: 6e2ec304689f ("dm-qcow2: Pause IO and notify about ENOSPC events")
Feature: dm-qcow2: block device over QCOW2 files driver
Signed-off-by: Alexander Ivanov <alexander.ivanov at virtuozzo.com>
---
 drivers/md/dm-qcow2-target.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/md/dm-qcow2-target.c b/drivers/md/dm-qcow2-target.c
index f4004f6095a7..c49b0f466867 100644
--- a/drivers/md/dm-qcow2-target.c
+++ b/drivers/md/dm-qcow2-target.c
@@ -254,6 +254,8 @@ static void qcow2_tgt_destroy(struct qcow2_target *tgt)
 		destroy_workqueue(tgt->wq);
 	}
 	qcow2_merge_backward_cancel(tgt);
+	timer_shutdown_sync(&tgt->enospc_timer);
+	cancel_work_sync(&tgt->event_work);
 
 	mempool_destroy(tgt->qio_pool);
 	mempool_destroy(tgt->qrq_pool);
-- 
2.53.0



More information about the Devel mailing list