[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 97/99] tap: fix memory leak on success to create a t
From: |
Michael Roth |
Subject: |
[Qemu-devel] [PATCH 97/99] tap: fix memory leak on success to create a tap device |
Date: |
Mon, 23 Jul 2018 15:17:46 -0500 |
From: Yunjian Wang <address@hidden>
The memory leak on success to create a tap device. And the nfds and
nvhosts may not be the same and need to be processed separately.
Fixes: 07825977 ("tap: fix memory leak on failure to create a multiqueue tap
device")
Fixes: 264986e2 ("tap: multiqueue support")
Cc: address@hidden
Signed-off-by: Yunjian Wang <address@hidden>
Signed-off-by: Jason Wang <address@hidden>
(cherry picked from commit 323e7c117754e4d4ce6b4282d74ad01c99d67714)
Signed-off-by: Michael Roth <address@hidden>
---
net/tap.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/net/tap.c b/net/tap.c
index 89c4e19162..e807e0ea2f 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -805,7 +805,8 @@ int net_init_tap(const Netdev *netdev, const char *name,
} else if (tap->has_fds) {
char **fds;
char **vhost_fds;
- int nfds, nvhosts;
+ int nfds = 0, nvhosts = 0;
+ int ret = 0;
if (tap->has_ifname || tap->has_script || tap->has_downscript ||
tap->has_vnet_hdr || tap->has_helper || tap->has_queues ||
@@ -825,6 +826,7 @@ int net_init_tap(const Netdev *netdev, const char *name,
if (nfds != nvhosts) {
error_setg(errp, "The number of fds passed does not match "
"the number of vhostfds passed");
+ ret = -1;
goto free_fail;
}
}
@@ -833,6 +835,7 @@ int net_init_tap(const Netdev *netdev, const char *name,
fd = monitor_fd_param(cur_mon, fds[i], &err);
if (fd == -1) {
error_propagate(errp, err);
+ ret = -1;
goto free_fail;
}
@@ -843,6 +846,7 @@ int net_init_tap(const Netdev *netdev, const char *name,
} else if (vnet_hdr != tap_probe_vnet_hdr(fd)) {
error_setg(errp,
"vnet_hdr not consistent across given tap fds");
+ ret = -1;
goto free_fail;
}
@@ -852,21 +856,21 @@ int net_init_tap(const Netdev *netdev, const char *name,
vnet_hdr, fd, &err);
if (err) {
error_propagate(errp, err);
+ ret = -1;
goto free_fail;
}
}
- g_free(fds);
- g_free(vhost_fds);
- return 0;
free_fail:
+ for (i = 0; i < nvhosts; i++) {
+ g_free(vhost_fds[i]);
+ }
for (i = 0; i < nfds; i++) {
g_free(fds[i]);
- g_free(vhost_fds[i]);
}
g_free(fds);
g_free(vhost_fds);
- return -1;
+ return ret;
} else if (tap->has_helper) {
if (tap->has_ifname || tap->has_script || tap->has_downscript ||
tap->has_vnet_hdr || tap->has_queues || tap->has_vhostfds) {
--
2.17.1
- [Qemu-devel] [PATCH 88/99] nfs: Remove processed options from QDict, (continued)
- [Qemu-devel] [PATCH 88/99] nfs: Remove processed options from QDict, Michael Roth, 2018/07/23
- [Qemu-devel] [PATCH 89/99] replace functions which are only available in glib-2.24, Michael Roth, 2018/07/23
- [Qemu-devel] [PATCH 90/99] vfio/pci: Default display option to "off", Michael Roth, 2018/07/23
- [Qemu-devel] [PATCH 91/99] migration/block-dirty-bitmap: fix dirty_bitmap_load, Michael Roth, 2018/07/23
- [Qemu-devel] [PATCH 08/99] target/ppc: always set PPC_MEM_TLBIE in pre 2.8 migration hack, Michael Roth, 2018/07/23
- [Qemu-devel] [PATCH 92/99] tcg: Reduce max TB opcode count, Michael Roth, 2018/07/23
- [Qemu-devel] [PATCH 94/99] iscsi: Avoid potential for get_status overflow, Michael Roth, 2018/07/23
- [Qemu-devel] [PATCH 93/99] nbd/server: Reject 0-length block status request, Michael Roth, 2018/07/23
- [Qemu-devel] [PATCH 95/99] virtio-rng: process pending requests on DRIVER_OK, Michael Roth, 2018/07/23
- [Qemu-devel] [PATCH 96/99] target/ppc: set is_jmp on ppc_tr_breakpoint_check, Michael Roth, 2018/07/23
- [Qemu-devel] [PATCH 97/99] tap: fix memory leak on success to create a tap device,
Michael Roth <=
- [Qemu-devel] [PATCH 98/99] qemu-img: avoid overflow of min_sparse parameter, Michael Roth, 2018/07/23