* [Qemu-devel] [PATCH v2] vhost-user: fix memory leak
@ 2018-02-13 5:08 linzhecheng
2018-02-13 16:27 ` Michael S. Tsirkin
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: linzhecheng @ 2018-02-13 5:08 UTC (permalink / raw)
To: qemu-devel; +Cc: pbonzini, mst, f4bug, wangxinxin.wang, lidonglin, linzhecheng
g_free() was moved from vhost_net_cleanup in commit e6bcb1b, so we should
free net after vhost_net_cleanup
Signed-off-by: linzhecheng <linzhecheng@huawei.com>
diff --git a/net/vhost-user.c b/net/vhost-user.c
index cb45512506..d024573e45 100644
--- a/net/vhost-user.c
+++ b/net/vhost-user.c
@@ -109,6 +109,7 @@ static int vhost_user_start(int queues, NetClientState *ncs[], CharBackend *be)
err:
if (net) {
vhost_net_cleanup(net);
+ g_free(net);
}
vhost_user_stop(i, ncs);
return -1;
--
2.12.2.windows.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH v2] vhost-user: fix memory leak
2018-02-13 5:08 [Qemu-devel] [PATCH v2] vhost-user: fix memory leak linzhecheng
@ 2018-02-13 16:27 ` Michael S. Tsirkin
2018-02-13 17:01 ` Marc-André Lureau
2018-02-13 20:37 ` Philippe Mathieu-Daudé
2 siblings, 0 replies; 4+ messages in thread
From: Michael S. Tsirkin @ 2018-02-13 16:27 UTC (permalink / raw)
To: linzhecheng; +Cc: qemu-devel, pbonzini, f4bug, wangxinxin.wang, lidonglin
On Tue, Feb 13, 2018 at 01:08:37PM +0800, linzhecheng wrote:
> g_free() was moved from vhost_net_cleanup in commit e6bcb1b, so we should
> free net after vhost_net_cleanup
>
> Signed-off-by: linzhecheng <linzhecheng@huawei.com>
Looks like this needs a Fixes: tag and CC stable - is that right?
> diff --git a/net/vhost-user.c b/net/vhost-user.c
> index cb45512506..d024573e45 100644
> --- a/net/vhost-user.c
> +++ b/net/vhost-user.c
> @@ -109,6 +109,7 @@ static int vhost_user_start(int queues, NetClientState *ncs[], CharBackend *be)
> err:
> if (net) {
> vhost_net_cleanup(net);
> + g_free(net);
> }
> vhost_user_stop(i, ncs);
> return -1;
> --
> 2.12.2.windows.2
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH v2] vhost-user: fix memory leak
2018-02-13 5:08 [Qemu-devel] [PATCH v2] vhost-user: fix memory leak linzhecheng
2018-02-13 16:27 ` Michael S. Tsirkin
@ 2018-02-13 17:01 ` Marc-André Lureau
2018-02-13 20:37 ` Philippe Mathieu-Daudé
2 siblings, 0 replies; 4+ messages in thread
From: Marc-André Lureau @ 2018-02-13 17:01 UTC (permalink / raw)
To: linzhecheng
Cc: QEMU, Michael S. Tsirkin, wangxinxin.wang,
Philippe Mathieu-Daudé, lidonglin, Paolo Bonzini
On Tue, Feb 13, 2018 at 6:08 AM, linzhecheng <linzhecheng@huawei.com> wrote:
> g_free() was moved from vhost_net_cleanup in commit e6bcb1b, so we should
> free net after vhost_net_cleanup
>
> Signed-off-by: linzhecheng <linzhecheng@huawei.com>
This can be reproduced and catched by ASAN too:
==11833==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 784 byte(s) in 1 object(s) allocated from:
#0 0x7fa1aed89a38 in __interceptor_calloc (/lib64/libasan.so.4+0xdea38)
#1 0x7fa1adadff75 in g_malloc0 ../glib/gmem.c:124
#2 0x56082a195515 in vhost_net_init
/home/elmarco/src/qemu/hw/net/vhost_net.c:147
#3 0x61500000bbff (<unknown module>)
good catch,
Reviewed-by: Marc-André Lureau < marcandre.lureau@redhat.com>
>
> diff --git a/net/vhost-user.c b/net/vhost-user.c
> index cb45512506..d024573e45 100644
> --- a/net/vhost-user.c
> +++ b/net/vhost-user.c
> @@ -109,6 +109,7 @@ static int vhost_user_start(int queues, NetClientState *ncs[], CharBackend *be)
> err:
> if (net) {
> vhost_net_cleanup(net);
> + g_free(net);
> }
> vhost_user_stop(i, ncs);
> return -1;
> --
> 2.12.2.windows.2
>
>
>
--
Marc-André Lureau
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH v2] vhost-user: fix memory leak
2018-02-13 5:08 [Qemu-devel] [PATCH v2] vhost-user: fix memory leak linzhecheng
2018-02-13 16:27 ` Michael S. Tsirkin
2018-02-13 17:01 ` Marc-André Lureau
@ 2018-02-13 20:37 ` Philippe Mathieu-Daudé
2 siblings, 0 replies; 4+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-02-13 20:37 UTC (permalink / raw)
To: linzhecheng, qemu-devel; +Cc: mst, wangxinxin.wang, lidonglin, pbonzini
On 02/13/2018 02:08 AM, linzhecheng wrote:
> g_free() was moved from vhost_net_cleanup in commit e6bcb1b, so we should
> free net after vhost_net_cleanup
>
> Signed-off-by: linzhecheng <linzhecheng@huawei.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>
> diff --git a/net/vhost-user.c b/net/vhost-user.c
> index cb45512506..d024573e45 100644
> --- a/net/vhost-user.c
> +++ b/net/vhost-user.c
> @@ -109,6 +109,7 @@ static int vhost_user_start(int queues, NetClientState *ncs[], CharBackend *be)
> err:
> if (net) {
> vhost_net_cleanup(net);
> + g_free(net);
> }
> vhost_user_stop(i, ncs);
> return -1;
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-02-13 20:37 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-13 5:08 [Qemu-devel] [PATCH v2] vhost-user: fix memory leak linzhecheng
2018-02-13 16:27 ` Michael S. Tsirkin
2018-02-13 17:01 ` Marc-André Lureau
2018-02-13 20:37 ` Philippe Mathieu-Daudé
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).