[PATCH] ramfb: avoid potential leak

marcandre.lureau@redhat.com posted 1 patch 7 months, 2 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20230920082634.3349487-1-marcandre.lureau@redhat.com
Maintainers: Gerd Hoffmann <kraxel@redhat.com>
hw/display/ramfb.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] ramfb: avoid potential leak
Posted by marcandre.lureau@redhat.com 7 months, 2 weeks ago
From: Marc-André Lureau <marcandre.lureau@redhat.com>

If the fwcfg is written several times (without surface being displayed
in the meantime), we may leak surfaces.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 hw/display/ramfb.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/display/ramfb.c b/hw/display/ramfb.c
index 4cd90a9382..116d674348 100644
--- a/hw/display/ramfb.c
+++ b/hw/display/ramfb.c
@@ -100,6 +100,7 @@ static void ramfb_fw_cfg_write(void *dev, off_t offset, size_t len)
 
     s->width = width;
     s->height = height;
+    g_clear_pointer(&s->ds, qemu_free_displaysurface);
     s->ds = surface;
 }
 
-- 
2.41.0