* [Qemu-devel] [PATCH] virtio-gpu: fix memory leak in resource attach backing
@ 2016-12-29 9:28 Li Qiang
2016-12-29 14:57 ` Marc-André Lureau
0 siblings, 1 reply; 4+ messages in thread
From: Li Qiang @ 2016-12-29 9:28 UTC (permalink / raw)
To: kraxel, marcandre.lureau, qemu-devel; +Cc: liqiang6-s, Li Qiang
In the resource attach backing function, everytime it will
allocate 'res->iov' thus can leading a memory leak. This
patch avoid this.
Signed-off-by: Li Qiang <liq3ea@gmail.com>
---
hw/display/virtio-gpu.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
index 5f32e1a..045f296 100644
--- a/hw/display/virtio-gpu.c
+++ b/hw/display/virtio-gpu.c
@@ -705,6 +705,11 @@ virtio_gpu_resource_attach_backing(VirtIOGPU *g,
return;
}
+ if (res->iov) {
+ cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC;
+ return;
+ }
+
ret = virtio_gpu_create_mapping_iov(&ab, cmd, &res->addrs, &res->iov);
if (ret != 0) {
cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] virtio-gpu: fix memory leak in resource attach backing
2016-12-29 9:28 [Qemu-devel] [PATCH] virtio-gpu: fix memory leak in resource attach backing Li Qiang
@ 2016-12-29 14:57 ` Marc-André Lureau
2016-12-30 6:13 ` Li Qiang
2017-01-03 9:41 ` Gerd Hoffmann
0 siblings, 2 replies; 4+ messages in thread
From: Marc-André Lureau @ 2016-12-29 14:57 UTC (permalink / raw)
To: Li Qiang; +Cc: kraxel, marcandre lureau, qemu-devel, liqiang6-s
Hi
----- Original Message -----
> In the resource attach backing function, everytime it will
> allocate 'res->iov' thus can leading a memory leak. This
> patch avoid this.
>
> Signed-off-by: Li Qiang <liq3ea@gmail.com>
> ---
> hw/display/virtio-gpu.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
> index 5f32e1a..045f296 100644
> --- a/hw/display/virtio-gpu.c
> +++ b/hw/display/virtio-gpu.c
> @@ -705,6 +705,11 @@ virtio_gpu_resource_attach_backing(VirtIOGPU *g,
> return;
> }
>
> + if (res->iov) {
> + cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC;
> + return;
> + }
> +
I think I would rather return an error in the library for this case.
> ret = virtio_gpu_create_mapping_iov(&ab, cmd, &res->addrs, &res->iov);
> if (ret != 0) {
> cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC;
> --
> 1.8.3.1
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] virtio-gpu: fix memory leak in resource attach backing
2016-12-29 14:57 ` Marc-André Lureau
@ 2016-12-30 6:13 ` Li Qiang
2017-01-03 9:41 ` Gerd Hoffmann
1 sibling, 0 replies; 4+ messages in thread
From: Li Qiang @ 2016-12-30 6:13 UTC (permalink / raw)
To: Marc-André Lureau; +Cc: kraxel, marcandre lureau, qemu-devel, Li Qiang
2016-12-29 22:57 GMT+08:00 Marc-André Lureau <mlureau@redhat.com>:
> Hi
>
> ----- Original Message -----
> > In the resource attach backing function, everytime it will
> > allocate 'res->iov' thus can leading a memory leak. This
> > patch avoid this.
> >
> > Signed-off-by: Li Qiang <liq3ea@gmail.com>
> > ---
> > hw/display/virtio-gpu.c | 5 +++++
> > 1 file changed, 5 insertions(+)
> >
> > diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
> > index 5f32e1a..045f296 100644
> > --- a/hw/display/virtio-gpu.c
> > +++ b/hw/display/virtio-gpu.c
> > @@ -705,6 +705,11 @@ virtio_gpu_resource_attach_backing(VirtIOGPU *g,
> > return;
> > }
> >
> > + if (res->iov) {
> > + cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC;
> > + return;
> > + }
> > +
>
> I think I would rather return an error in the library for this case.
>
>
IIUC Do you mean virglrenderer library? There is no related to this library.
Thanks.
> > ret = virtio_gpu_create_mapping_iov(&ab, cmd, &res->addrs,
> &res->iov);
> > if (ret != 0) {
> > cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC;
> > --
> > 1.8.3.1
> >
> >
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] virtio-gpu: fix memory leak in resource attach backing
2016-12-29 14:57 ` Marc-André Lureau
2016-12-30 6:13 ` Li Qiang
@ 2017-01-03 9:41 ` Gerd Hoffmann
1 sibling, 0 replies; 4+ messages in thread
From: Gerd Hoffmann @ 2017-01-03 9:41 UTC (permalink / raw)
To: Marc-André Lureau; +Cc: Li Qiang, marcandre lureau, qemu-devel, liqiang6-s
> > + if (res->iov) {
> > + cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC;
> > + return;
> > + }
> > +
>
> I think I would rather return an error in the library for this case.
-ENOLIBRARY ;)
This is the 2d mode code, so virglrenderer isn't involved at all.
Added patch to the queue (and the 3d one too).
thanks,
Gerd
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-01-03 9:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-29 9:28 [Qemu-devel] [PATCH] virtio-gpu: fix memory leak in resource attach backing Li Qiang
2016-12-29 14:57 ` Marc-André Lureau
2016-12-30 6:13 ` Li Qiang
2017-01-03 9:41 ` Gerd Hoffmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).