Skip to contentSkip to conversation

ui/gtk: making dmabuf NULL when it's released.

PATCH Superseded Dongwon Kim 2 participants 3 messages Jun 21, 2023 – Jun 27, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ui/gtk: making dmabuf NULL when it's released.

Set vc->gfx.guest_fb.dmabuf to NULL to prevent any further access to it after the dmabuf is released.

Cc Gerd Hoffmann <[email protected]>
Cc Marc-André Lureau <[email protected]>
Cc Vivek Kasireddy <[email protected]>
---
 ui/gtk.c | 4 ++++
 1 file changed, 4 insertions(+)
ui/gtk.c +4 -0
index e50f950f2b..0b8bf8ea8a 100644
@@ -587,8 +587,12 @@ static bool gd_has_dmabuf(DisplayChangeListener *dcl)
 static void gd_gl_release_dmabuf(DisplayChangeListener *dcl,
                                  QemuDmaBuf *dmabuf)
 {
+    VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl);
 #ifdef CONFIG_GBM
     egl_dmabuf_release_texture(dmabuf);
+    if (vc->gfx.guest_fb.dmabuf == dmabuf) {
+        vc->gfx.guest_fb.dmabuf = NULL;
+    }
 #endif
 }
 
Signature · 1 line
2.34.1
#1 lore raw

ui/gtk.c static bool gd_has_dmabuf(DisplayChangeListener *dcl) · line 597

Quoted 11 lines · Dongwon Kim

static void gd_gl_release_dmabuf(DisplayChangeListener *dcl,
QemuDmaBuf *dmabuf)
{

ui/gtk.c +4 -0
+    VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl);
  #ifdef CONFIG_GBM
      egl_dmabuf_release_texture(dmabuf);
+    if (vc->gfx.guest_fb.dmabuf == dmabuf) {
+        vc->gfx.guest_fb.dmabuf = NULL;
+    }
  #endif
  }

Conditionally unused variable outside the ifdef.

r~

#2 lore raw

PATCH v2 1/1 ui/gtk: making dmabuf NULL when it's released.

Set vc->gfx.guest_fb.dmabuf to NULL to prevent any further access to it after the dmabuf is released.

v2: move declaration of vc inside ifdef

Cc Gerd Hoffmann <[email protected]>
Cc Marc-André Lureau <[email protected]>
Cc Vivek Kasireddy <[email protected]>
---
 ui/gtk.c | 5 +++++
 1 file changed, 5 insertions(+)
ui/gtk.c +5 -0
index e50f950f2b..2a9a0d23e6 100644
@@ -588,7 +588,12 @@ static void gd_gl_release_dmabuf(DisplayChangeListener *dcl,
                                  QemuDmaBuf *dmabuf)
 {
 #ifdef CONFIG_GBM
+    VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl);
+
     egl_dmabuf_release_texture(dmabuf);
+    if (vc->gfx.guest_fb.dmabuf == dmabuf) {
+        vc->gfx.guest_fb.dmabuf = NULL;
+    }
 #endif
 }
 
Signature · 1 line
2.34.1