[Devel] [PATCH rh9] drivers/vhost: Don't panic on double flush of a virtqueue
Konstantin Khorenko
khorenko at virtuozzo.com
Thu Sep 22 14:52:40 MSK 2022
From: Alexander Atanasov <alexander.atanasov at virtuozzo.com>
vhost_net_release() calls vhost_net_flush() after vhost_dev_cleanup(),
trying to flush already flushed vhost_worker.
vhost_net_release()
vhost_dev_cleanup()
vhost_cleanup_workers()
vhost_worker_reset()
w->worker = NULL; // !!!
vhost_net_flush()
vhost_net_flush_vq()
vhost_poll_flush()
vhost_work_flush_vq()
if (!w) // w != NULL, but w->worker == NULL
return;
vhost_worker_flush(w)
vhost_work_queue_at_worker(w)
wake_up_process(w->worker) // crash
https://jira.sw.ru/browse/PSBM-142058
Fixes: f45287479ce4 ("drivers/vhost: add API to queue work at virtqueue
worker")
Signed-off-by: Alexander Atanasov <alexander.atanasov at virtuozzo.com>
Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
drivers/vhost/vhost.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index cac369ca6f0c..6f40018adda5 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -284,7 +284,7 @@ void vhost_work_flush_vq(struct vhost_virtqueue *vq)
{
struct vhost_worker *w = READ_ONCE(vq->worker);
- if (!w)
+ if (!w || !w->worker)
return;
vhost_worker_flush(w);
--
2.31.1
More information about the Devel
mailing list