diff mbox series

[v2,1/2] vfio/display: Fix potential memleak of edid info

Message ID 20240701014809.255682-2-zhenzhong.duan@intel.com (mailing list archive)
State New
Headers show
Series Misc fixes on vfio display | expand

Commit Message

Duan, Zhenzhong July 1, 2024, 1:48 a.m. UTC
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 <zhenzhong.duan@intel.com>
---
 hw/vfio/display.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Cédric Le Goater July 2, 2024, 3:25 p.m. UTC | #1
On 7/1/24 3:48 AM, Zhenzhong Duan wrote:
> 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 <zhenzhong.duan@intel.com>


Reviewed-by: Cédric Le Goater <clg@redhat.com>

Thanks,

C.


> ---
>   hw/vfio/display.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> 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);
Marc-André Lureau July 2, 2024, 3:31 p.m. UTC | #2
On Mon, Jul 1, 2024 at 5:51 AM Zhenzhong Duan <zhenzhong.duan@intel.com>
wrote:

> 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 <zhenzhong.duan@intel.com>
>

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


> ---
>  hw/vfio/display.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> 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);
> --
> 2.34.1
>
>
>
diff mbox series

Patch

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);