diff mbox

[3/6] virtio-gpu: fix memory leak in error path

Message ID 1452686548-6291-4-git-send-email-kraxel@redhat.com
State New
Headers show

Commit Message

Gerd Hoffmann Jan. 13, 2016, 12:02 p.m. UTC
Found by Coverity Scan, buf not freed on error.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/display/virtio-gpu-3d.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Marc-André Lureau Jan. 13, 2016, 1:09 p.m. UTC | #1
Hi

On Wed, Jan 13, 2016 at 1:02 PM, Gerd Hoffmann <kraxel@redhat.com> wrote:
> Found by Coverity Scan, buf not freed on error.
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---

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

>  hw/display/virtio-gpu-3d.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/hw/display/virtio-gpu-3d.c b/hw/display/virtio-gpu-3d.c
> index 28dccfd..d2af327 100644
> --- a/hw/display/virtio-gpu-3d.c
> +++ b/hw/display/virtio-gpu-3d.c
> @@ -197,7 +197,7 @@ static void virgl_cmd_submit_3d(VirtIOGPU *g,
>          qemu_log_mask(LOG_GUEST_ERROR, "%s: size mismatch (%zd/%d)",
>                        __func__, s, cs.size);
>          cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_PARAMETER;
> -        return;
> +        goto out;
>      }
>
>      if (virtio_gpu_stats_enabled(g->conf)) {
> @@ -207,6 +207,7 @@ static void virgl_cmd_submit_3d(VirtIOGPU *g,
>
>      virgl_renderer_submit_cmd(buf, cs.hdr.ctx_id, cs.size / 4);
>
> +out:
>      g_free(buf);
>  }
>
> --
> 1.8.3.1
>
diff mbox

Patch

diff --git a/hw/display/virtio-gpu-3d.c b/hw/display/virtio-gpu-3d.c
index 28dccfd..d2af327 100644
--- a/hw/display/virtio-gpu-3d.c
+++ b/hw/display/virtio-gpu-3d.c
@@ -197,7 +197,7 @@  static void virgl_cmd_submit_3d(VirtIOGPU *g,
         qemu_log_mask(LOG_GUEST_ERROR, "%s: size mismatch (%zd/%d)",
                       __func__, s, cs.size);
         cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_PARAMETER;
-        return;
+        goto out;
     }
 
     if (virtio_gpu_stats_enabled(g->conf)) {
@@ -207,6 +207,7 @@  static void virgl_cmd_submit_3d(VirtIOGPU *g,
 
     virgl_renderer_submit_cmd(buf, cs.hdr.ctx_id, cs.size / 4);
 
+out:
     g_free(buf);
 }