diff mbox

virtio-gpu: fix memory leak in update_cursor_data_virgl

Message ID 58187760.41d71c0a.cca75.4cb9@mx.google.com (mailing list archive)
State New, archived
Headers show

Commit Message

Li Qiang Nov. 1, 2016, 11:06 a.m. UTC
From: Li Qiang <liqiang6-s@360.cn>

In update_cursor_data_virgl function, if the 'width'/ 'height'
is not equal to current cursor's width/height it will return
without free the 'data' allocated previously. This will lead
a memory leak issue. This patch fix this issue.

Signed-off-by: Li Qiang <liqiang6-s@360.cn>
---
 hw/display/virtio-gpu.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Gerd Hoffmann Nov. 1, 2016, 11:16 a.m. UTC | #1
On Di, 2016-11-01 at 04:06 -0700, Li Qiang wrote:
> From: Li Qiang <liqiang6-s@360.cn>
> 
> In update_cursor_data_virgl function, if the 'width'/ 'height'
> is not equal to current cursor's width/height it will return
> without free the 'data' allocated previously. This will lead
> a memory leak issue. This patch fix this issue.
> 
> Signed-off-by: Li Qiang <liqiang6-s@360.cn>
> ---
>  hw/display/virtio-gpu.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
> index 60bce94..5f32e1a 100644
> --- a/hw/display/virtio-gpu.c
> +++ b/hw/display/virtio-gpu.c
> @@ -84,6 +84,7 @@ static void update_cursor_data_virgl(VirtIOGPU *g,
>  
>      if (width != s->current_cursor->width ||
>          height != s->current_cursor->height) {
> +        free(data);
>          return;
>      }
>  

Added to vga patch queue.

thanks,
  Gerd
Marc-André Lureau Nov. 1, 2016, 11:17 a.m. UTC | #2
Hi

On Tue, Nov 1, 2016 at 2:07 PM Li Qiang <liq3ea@gmail.com> wrote:

> From: Li Qiang <liqiang6-s@360.cn>
>
> In update_cursor_data_virgl function, if the 'width'/ 'height'
> is not equal to current cursor's width/height it will return
> without free the 'data' allocated previously. This will lead
> a memory leak issue. This patch fix this issue.
>
> Signed-off-by: Li Qiang <liqiang6-s@360.cn>
>


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


---
>  hw/display/virtio-gpu.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
> index 60bce94..5f32e1a 100644
> --- a/hw/display/virtio-gpu.c
> +++ b/hw/display/virtio-gpu.c
> @@ -84,6 +84,7 @@ static void update_cursor_data_virgl(VirtIOGPU *g,
>
>      if (width != s->current_cursor->width ||
>          height != s->current_cursor->height) {
> +        free(data);
>          return;
>      }
>
> --
> 1.8.3.1
>
>
> --
Marc-André Lureau
diff mbox

Patch

diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
index 60bce94..5f32e1a 100644
--- a/hw/display/virtio-gpu.c
+++ b/hw/display/virtio-gpu.c
@@ -84,6 +84,7 @@  static void update_cursor_data_virgl(VirtIOGPU *g,
 
     if (width != s->current_cursor->width ||
         height != s->current_cursor->height) {
+        free(data);
         return;
     }