[email protected] writes:

> From: Marc-André Lureau <[email protected]>
>
> virtio_gpu_virgl_reset() does not free the bottom halves or timers
> allocated by the previous virtio_gpu_virgl_init() call. A subsequent
> virtio_gpu_virgl_init() overwrites the old pointers, leaking the
> previous allocations.
>
> Fixes: bd9258917fbf ("virtio-gpu: Destroy virgl resources on virtio-gpu 
> reset")
> Signed-off-by: Marc-André Lureau <[email protected]>
> ---
>  hw/display/virtio-gpu-virgl.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c
> index 0b79aef8d1f5..8bf6417c6514 100644
> --- a/hw/display/virtio-gpu-virgl.c
> +++ b/hw/display/virtio-gpu-virgl.c
> @@ -1425,6 +1425,7 @@ void virtio_gpu_virgl_reset_scanout(VirtIOGPU *g)
>  
>  static bool virtio_gpu_virgl_reset(VirtIOGPU *g)
>  {
> +    VirtIOGPUGL *gl = VIRTIO_GPU_GL(g);
>      struct virtio_gpu_simple_resource *res, *tmp;
>  
>      /*
> @@ -1443,6 +1444,11 @@ static bool virtio_gpu_virgl_reset(VirtIOGPU *g)
>  
>      virtio_gpu_virgl_reset_async_fences(g);
>  
> +    g_clear_pointer(&gl->cmdq_resume_bh, qemu_bh_delete);
> +    g_clear_pointer(&gl->async_fence_bh, qemu_bh_delete);
> +    g_clear_pointer(&gl->print_stats, timer_free);
> +    g_clear_pointer(&gl->fence_poll, timer_free);
> +

Don't we need some ptr checks in virtio_gpu_gl_device_unrealize so a
reset followed by an unplug doesn't causes segs chasing now NULL
pointers?


>      return true;
>  }

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro

Reply via email to