summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryuanjungong2020-11-19 10:25:32 +0100
committerJason Wang2020-11-24 03:40:17 +0100
commitf012bec8909820390936f1cf68b3e73a2d4ac966 (patch)
tree53c8dbf61b4434acb699dc63e29ace951faebb00
parentnet: purge queued rx packets on queue deletion (diff)
downloadqemu-f012bec8909820390936f1cf68b3e73a2d4ac966.tar.gz
qemu-f012bec8909820390936f1cf68b3e73a2d4ac966.tar.xz
qemu-f012bec8909820390936f1cf68b3e73a2d4ac966.zip
tap: fix a memory leak
Close fd before returning. Buglink: https://bugs.launchpad.net/qemu/+bug/1904486 Signed-off-by: yuanjungong <ruc_gongyuanjun@163.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Jason Wang <jasowang@redhat.com>
-rw-r--r--net/tap.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/net/tap.c b/net/tap.c
index c46ff66184..fe95fa7073 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -817,6 +817,7 @@ int net_init_tap(const Netdev *netdev, const char *name,
if (ret < 0) {
error_setg_errno(errp, -ret, "%s: Can't use file descriptor %d",
name, fd);
+ close(fd);
return -1;
}
@@ -831,6 +832,7 @@ int net_init_tap(const Netdev *netdev, const char *name,
vhostfdname, vnet_hdr, fd, &err);
if (err) {
error_propagate(errp, err);
+ close(fd);
return -1;
}
} else if (tap->has_fds) {