aboutsummaryrefslogtreecommitdiff
path: root/net/tap.c
diff options
context:
space:
mode:
authoryuanjungong <ruc_gongyuanjun@163.com>2020-11-19 17:25:32 +0800
committerJason Wang <jasowang@redhat.com>2020-11-24 10:40:17 +0800
commitf012bec8909820390936f1cf68b3e73a2d4ac966 (patch)
tree53c8dbf61b4434acb699dc63e29ace951faebb00 /net/tap.c
parentd2abc563e4ba4057b9cb5c04dd203b8c3a949115 (diff)
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>
Diffstat (limited to 'net/tap.c')
-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) {