All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ui/console: remove console from global list on finalization
@ 2026-04-22 20:26 marcandre.lureau
  2026-04-23  5:02 ` Markus Armbruster
  2026-04-24  6:50 ` Markus Armbruster
  0 siblings, 2 replies; 10+ messages in thread
From: marcandre.lureau @ 2026-04-22 20:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: armbru, Marc-André Lureau

From: Marc-André Lureau <marcandre.lureau@redhat.com>

This commit removes the QemuConsole from the global "consoles" list when
it is finalized.

Previously, there was a TODO comment indicating this path needed
checking. The assertions added ensure that `dcls`, `gl_block`, and the
`dump_queue` are empty before removal, confirming the console is in a
clean state.

Fix potential use-after-free crashes when a display console is removed.

Reported-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 ui/console.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/ui/console.c b/ui/console.c
index f445db11389..b64e2122f34 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -394,10 +394,13 @@ qemu_console_finalize(Object *obj)
 {
     QemuConsole *c = QEMU_CONSOLE(obj);
 
-    /* TODO: check this code path, and unregister from consoles */
+    assert(c->dcls == 0);
+    assert(c->gl_block == 0);
+    assert(qemu_co_queue_empty(&c->dump_queue));
     g_clear_pointer(&c->surface, qemu_free_displaysurface);
     g_clear_pointer(&c->gl_unblock_timer, timer_free);
     g_clear_pointer(&c->ui_timer, timer_free);
+    QTAILQ_REMOVE(&consoles, c, next);
 }
 
 static void
-- 
2.53.0



^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2026-04-27  9:21 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-22 20:26 [PATCH] ui/console: remove console from global list on finalization marcandre.lureau
2026-04-23  5:02 ` Markus Armbruster
2026-04-23  6:28   ` Marc-André Lureau
2026-04-23  6:59     ` Markus Armbruster
2026-04-23  8:02       ` Marc-André Lureau
2026-04-23 10:57         ` Markus Armbruster
2026-04-27  8:13           ` Marc-André Lureau
2026-04-24  6:50 ` Markus Armbruster
2026-04-27  8:17   ` Marc-André Lureau
2026-04-27  9:20     ` Markus Armbruster

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.