From: Zhenzhong Duan Date: Mon, 1 Jul 2024 01:48:08 +0000 (+0800) Subject: vfio/display: Fix potential memleak of edid info X-Git-Tag: pull-vmclock-20250108~255^2~1 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=f15da599a1c5326e105425a74d2fb004a2a2649e;p=users%2Fdwmw2%2Fqemu.git vfio/display: Fix potential memleak of edid info EDID related device region info is leaked in vfio_display_edid_init() error path and VFIODisplay destroying path. Fixes: 08479114b0de ("vfio/display: add edid support.") Signed-off-by: Zhenzhong Duan Reviewed-by: Cédric Le Goater Reviewed-by: Marc-André Lureau --- diff --git a/hw/vfio/display.c b/hw/vfio/display.c index 661e921616..9c57fd3888 100644 --- a/hw/vfio/display.c +++ b/hw/vfio/display.c @@ -171,7 +171,9 @@ static void vfio_display_edid_init(VFIOPCIDevice *vdev) err: trace_vfio_display_edid_write_error(); + g_free(dpy->edid_info); g_free(dpy->edid_regs); + dpy->edid_info = NULL; dpy->edid_regs = NULL; return; } @@ -182,6 +184,7 @@ static void vfio_display_edid_exit(VFIODisplay *dpy) return; } + g_free(dpy->edid_info); g_free(dpy->edid_regs); g_free(dpy->edid_blob); timer_free(dpy->edid_link_timer);