Skip to content

Commit f47a47e

Browse files
jasowangmstsirkin
authored andcommitted
vhost-vdpa: don't cleanup twice in vhost_vdpa_add()
The previous vhost_net_cleanup is sufficient for freeing, calling vhost_vdpa_del() in this case will lead an extra round of free. Note that this kind of "double free" is safe since vhost_dev_cleanup() zero the whole structure. Reviewed-by: Stefano Garzarella <[email protected]> Signed-off-by: Jason Wang <[email protected]> Message-Id: <[email protected]> Reviewed-by: Michael S. Tsirkin <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]>
1 parent 9ff7a54 commit f47a47e

File tree

1 file changed

+0
-11
lines changed

1 file changed

+0
-11
lines changed

net/vhost-vdpa.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,6 @@ static int vhost_vdpa_net_check_device_id(struct vhost_net *net)
8181
return ret;
8282
}
8383

84-
static void vhost_vdpa_del(NetClientState *ncs)
85-
{
86-
VhostVDPAState *s;
87-
assert(ncs->info->type == NET_CLIENT_DRIVER_VHOST_VDPA);
88-
s = DO_UPCAST(VhostVDPAState, nc, ncs);
89-
if (s->vhost_net) {
90-
vhost_net_cleanup(s->vhost_net);
91-
}
92-
}
93-
9484
static int vhost_vdpa_add(NetClientState *ncs, void *be)
9585
{
9686
VhostNetOptions options;
@@ -121,7 +111,6 @@ static int vhost_vdpa_add(NetClientState *ncs, void *be)
121111
if (net) {
122112
vhost_net_cleanup(net);
123113
}
124-
vhost_vdpa_del(ncs);
125114
return -1;
126115
}
127116

0 commit comments

Comments
 (0)