Skip to contentSkip to conversation

vhost-user: fix memory leak

PATCH Superseded linzhecheng 2 participants 4 messages Feb 13, 2018 Networking

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vhost-user: fix memory leak

fix memory leak

net/vhost-user.c +1 -0
index cb45512506..d024573e45 100644
@@ -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;
Signature · 1 line
2.12.2.windows.2
#1 lore raw

Hi Linzhecheng,

net/vhost-user.c static int vhost_user_start(int queues, NetClientState *ncs[], CharBackend *be) · line 112

Quoted 13 lines · linzhecheng

fix memory leak

net/vhost-user.c +1 -0
index cb45512506..d024573e45 100644
@@ -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);

I think this g_free() belongs to vhost_net_cleanup() in net/vhost_net.c:

void vhost_net_cleanup(struct vhost_net *net)

{
    vhost_dev_cleanup(&net->dev);
    g_free(net);
}

Regards,

Phil.

Quoted 4 lines
net/vhost-user.c +0 -0
     }
     vhost_user_stop(i, ncs);
     return -1;
#2 lore raw
Quoted 18 lines

-----邮件原件-----
发件人: Philippe Mathieu-Daudé [mailto:[email protected]] 代表 Philippe Mathieu-Daudé
发送时间: 2018年2月13日 11:54
收件人: linzhecheng <[email protected]>; [email protected] 抄送: [email protected]; wangxin (U) <[email protected]>; lidonglin <[email protected]>; [email protected]
主题: Re: [Qemu-devel] [PATCH] vhost-user: fix memory leak

Hi Linzhecheng,

Quoted 4 lines · linzhecheng

fix memory leak

Quoted 12 lines

net/vhost-user.c static int vhost_user_start(int queues, · line 113

Quoted 10 lines
net/vhost-user.c index renamed from net/vhost-user.c +0 -0

cb45512506..d024573e45 100644

net/vhost-user.c +1 -0
@@ -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);

I think this g_free() belongs to vhost_net_cleanup() in net/vhost_net.c:

I think your qemu version is out of date, g_free was moved from vhost_net_cleanup in commit e6bcb1b

Quoted 14 lines
void vhost_net_cleanup(struct vhost_net *net) {
    vhost_dev_cleanup(&net->dev);
    g_free(net);
}

Regards,

Phil.

Quoted 4 lines
net/vhost-user.c +0 -0
     }
     vhost_user_stop(i, ncs);
     return -1;
#3 lore raw
Quoted 28 lines · linzhecheng
Quoted 16 lines

-----邮件原件-----
发件人: Philippe Mathieu-Daudé [mailto:[email protected]] 代表 Philippe Mathieu-Daudé
发送时间: 2018年2月13日 11:54
收件人: linzhecheng <[email protected]>; [email protected] 抄送: [email protected]; wangxin (U) <[email protected]>; lidonglin <[email protected]>; [email protected]
主题: Re: [Qemu-devel] [PATCH] vhost-user: fix memory leak

Hi Linzhecheng,

Quoted 4 lines · linzhecheng

fix memory leak

Quoted 12 lines

net/vhost-user.c static int vhost_user_start(int queues, · line 113

Quoted 10 lines
net/vhost-user.c index renamed from net/vhost-user.c +0 -0

cb45512506..d024573e45 100644

net/vhost-user.c +1 -0
@@ -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);

I think this g_free() belongs to vhost_net_cleanup() in net/vhost_net.c:

Quoted 1 line

I think your qemu version is out of date, g_free was moved from vhost_net_cleanup in commit e6bcb1b

Now reading e6bcb1b I can understand your patch.

Can you add a reference to this commit in your patch description?

"g_free was moved from vhost_net_cleanup in commit e6bcb1b" might be enough.

Adding reference:

Quoted 14 lines
Quoted 14 lines
void vhost_net_cleanup(struct vhost_net *net) {
    vhost_dev_cleanup(&net->dev);
    g_free(net);
}

Regards,

Phil.

Quoted 4 lines
net/vhost-user.c +0 -0
     }
     vhost_user_stop(i, ncs);
     return -1;