[PATCH-for-5.0 0/3] virtio,vhost-gpu: Release memory returned by malloc() with free()

Philippe Mathieu-Daudé posted 3 patches 5 years, 7 months ago
Test docker-mingw@fedora passed
Test docker-quick@centos7 passed
Test checkpatch passed
Test FreeBSD passed
Test asan passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20200323112943.12010-1-philmd@redhat.com
Maintainers: "Marc-André Lureau" <marcandre.lureau@redhat.com>, Gerd Hoffmann <kraxel@redhat.com>, "Michael S. Tsirkin" <mst@redhat.com>
include/hw/virtio/virtio.h              | 8 ++++++++
contrib/vhost-user-gpu/vhost-user-gpu.c | 4 ++--
contrib/vhost-user-gpu/virgl.c          | 2 +-
hw/display/virtio-gpu-3d.c              | 2 +-
hw/display/virtio-gpu.c                 | 8 ++++----
5 files changed, 16 insertions(+), 8 deletions(-)
[PATCH-for-5.0 0/3] virtio,vhost-gpu: Release memory returned by malloc() with free()
Posted by Philippe Mathieu-Daudé 5 years, 7 months ago
Coverity reported a ALLOC_FREE_MISMATCH in vg_handle_cursor(),
because the memory returned by vu_queue_pop() is allocated with
malloc(). Fix it.

Similar error occurs with virtio. Document and fix.

Philippe Mathieu-Daudé (3):
  vhost-user-gpu: Release memory returned by vu_queue_pop() with free()
  virtio: Document virtqueue_pop()
  virtio-gpu: Release memory returned by virtqueue_pop() with free()

 include/hw/virtio/virtio.h              | 8 ++++++++
 contrib/vhost-user-gpu/vhost-user-gpu.c | 4 ++--
 contrib/vhost-user-gpu/virgl.c          | 2 +-
 hw/display/virtio-gpu-3d.c              | 2 +-
 hw/display/virtio-gpu.c                 | 8 ++++----
 5 files changed, 16 insertions(+), 8 deletions(-)

-- 
2.21.1


Re: [PATCH-for-5.0 0/3] virtio, vhost-gpu: Release memory returned by malloc() with free()
Posted by Michael S. Tsirkin 5 years, 7 months ago
On Mon, Mar 23, 2020 at 12:29:40PM +0100, Philippe Mathieu-Daudé wrote:
> Coverity reported a ALLOC_FREE_MISMATCH in vg_handle_cursor(),
> because the memory returned by vu_queue_pop() is allocated with
> malloc(). Fix it.
> 
> Similar error occurs with virtio. Document and fix.

I will queue this. Thanks!

> Philippe Mathieu-Daudé (3):
>   vhost-user-gpu: Release memory returned by vu_queue_pop() with free()
>   virtio: Document virtqueue_pop()
>   virtio-gpu: Release memory returned by virtqueue_pop() with free()
> 
>  include/hw/virtio/virtio.h              | 8 ++++++++
>  contrib/vhost-user-gpu/vhost-user-gpu.c | 4 ++--
>  contrib/vhost-user-gpu/virgl.c          | 2 +-
>  hw/display/virtio-gpu-3d.c              | 2 +-
>  hw/display/virtio-gpu.c                 | 8 ++++----
>  5 files changed, 16 insertions(+), 8 deletions(-)
> 
> -- 
> 2.21.1


Re: [PATCH-for-5.0 0/3] virtio, vhost-gpu: Release memory returned by malloc() with free()
Posted by Michael S. Tsirkin 5 years, 7 months ago
On Mon, Mar 23, 2020 at 09:41:20AM -0400, Michael S. Tsirkin wrote:
> On Mon, Mar 23, 2020 at 12:29:40PM +0100, Philippe Mathieu-Daudé wrote:
> > Coverity reported a ALLOC_FREE_MISMATCH in vg_handle_cursor(),
> > because the memory returned by vu_queue_pop() is allocated with
> > malloc(). Fix it.
> > 
> > Similar error occurs with virtio. Document and fix.
> 
> I will queue this. Thanks!

So what are we doing with this patchset? Marc-André reported issues -
any plan to fix them up? Split up the patchset to 3 independent
patches?

> > Philippe Mathieu-Daudé (3):
> >   vhost-user-gpu: Release memory returned by vu_queue_pop() with free()
> >   virtio: Document virtqueue_pop()
> >   virtio-gpu: Release memory returned by virtqueue_pop() with free()
> > 
> >  include/hw/virtio/virtio.h              | 8 ++++++++
> >  contrib/vhost-user-gpu/vhost-user-gpu.c | 4 ++--
> >  contrib/vhost-user-gpu/virgl.c          | 2 +-
> >  hw/display/virtio-gpu-3d.c              | 2 +-
> >  hw/display/virtio-gpu.c                 | 8 ++++----
> >  5 files changed, 16 insertions(+), 8 deletions(-)
> > 
> > -- 
> > 2.21.1


Re: [PATCH-for-5.0 0/3] virtio, vhost-gpu: Release memory returned by malloc() with free()
Posted by Philippe Mathieu-Daudé 5 years, 7 months ago
On 4/13/20 12:59 PM, Michael S. Tsirkin wrote:
> On Mon, Mar 23, 2020 at 09:41:20AM -0400, Michael S. Tsirkin wrote:
>> On Mon, Mar 23, 2020 at 12:29:40PM +0100, Philippe Mathieu-Daudé wrote:
>>> Coverity reported a ALLOC_FREE_MISMATCH in vg_handle_cursor(),
>>> because the memory returned by vu_queue_pop() is allocated with
>>> malloc(). Fix it.
>>>
>>> Similar error occurs with virtio. Document and fix.
>>
>> I will queue this. Thanks!
> 
> So what are we doing with this patchset? Marc-André reported issues -
> any plan to fix them up? Split up the patchset to 3 independent
> patches?

As noted Marc-André, patches 2 & 3 are incorrect.

Patch 1 can be queued as it with no modification.

> 
>>> Philippe Mathieu-Daudé (3):
>>>    vhost-user-gpu: Release memory returned by vu_queue_pop() with free()
>>>    virtio: Document virtqueue_pop()
>>>    virtio-gpu: Release memory returned by virtqueue_pop() with free()
>>>
>>>   include/hw/virtio/virtio.h              | 8 ++++++++
>>>   contrib/vhost-user-gpu/vhost-user-gpu.c | 4 ++--
>>>   contrib/vhost-user-gpu/virgl.c          | 2 +-
>>>   hw/display/virtio-gpu-3d.c              | 2 +-
>>>   hw/display/virtio-gpu.c                 | 8 ++++----
>>>   5 files changed, 16 insertions(+), 8 deletions(-)
>>>
>>> -- 
>>> 2.21.1
>