diff mbox series

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

Message ID 20230621221134.29802-1-dongwon.kim@intel.com (mailing list archive)
State New, archived
Headers show
Series ui/gtk: making dmabuf NULL when it's released. | expand

Commit Message

Kim, Dongwon June 21, 2023, 10:11 p.m. UTC
Set vc->gfx.guest_fb.dmabuf to NULL to prevent any further access
to it after the dmabuf is released.

Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
Cc: Vivek Kasireddy <vivek.kasireddy@intel.com>
Signed-off-by: Dongwon Kim <dongwon.kim@intel.com>
---
 ui/gtk.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Richard Henderson June 22, 2023, 5:02 a.m. UTC | #1
On 6/22/23 00:11, Dongwon Kim wrote:
>   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
>   }

Conditionally unused variable outside the ifdef.

r~
diff mbox series

Patch

diff --git a/ui/gtk.c b/ui/gtk.c
index e50f950f2b..0b8bf8ea8a 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -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
 }