diff options
author | yuanjungong <ruc_gongyuanjun@163.com> | 2020-11-19 17:25:32 +0800 |
---|---|---|
committer | Jason Wang <jasowang@redhat.com> | 2020-11-24 10:40:17 +0800 |
commit | f012bec8909820390936f1cf68b3e73a2d4ac966 (patch) | |
tree | 53c8dbf61b4434acb699dc63e29ace951faebb00 /net/tap.c | |
parent | d2abc563e4ba4057b9cb5c04dd203b8c3a949115 (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.c | 2 |
1 files changed, 2 insertions, 0 deletions
@@ -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) { |