Skip to content

Commit

Permalink
tap: fix a memory leak
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
AnnYugawa authored and jasowang committed Nov 24, 2020
1 parent d2abc56 commit f012bec
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions net/tap.c
Expand Up @@ -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;
}

Expand All @@ -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) {
Expand Down

0 comments on commit f012bec

Please sign in to comment.