All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: peter.maydell@linaro.org, qemu-devel@nongnu.org
Cc: yuanjungong <ruc_gongyuanjun@163.com>, Jason Wang <jasowang@redhat.com>
Subject: [PULL 4/5] tap: fix a memory leak
Date: Tue, 24 Nov 2020 10:44:22 +0800	[thread overview]
Message-ID: <1606185863-25996-5-git-send-email-jasowang@redhat.com> (raw)
In-Reply-To: <1606185863-25996-1-git-send-email-jasowang@redhat.com>

From: yuanjungong <ruc_gongyuanjun@163.com>

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>
---
 net/tap.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/tap.c b/net/tap.c
index c46ff66..fe95fa7 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) {
-- 
2.7.4



  parent reply	other threads:[~2020-11-24  2:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-24  2:44 [PULL 0/5] Net patches Jason Wang
2020-11-24  2:44 ` [PULL 1/5] hw/net/e1000e: advance desc_offset in case of null descriptor Jason Wang
2020-11-24  2:44 ` [PULL 2/5] net: do not exit on "netdev_add help" monitor command Jason Wang
2020-11-24  2:44 ` [PULL 3/5] net: purge queued rx packets on queue deletion Jason Wang
2020-11-24  2:44 ` Jason Wang [this message]
2020-11-24  2:44 ` [PULL 5/5] net: Use correct default-path macro for downscript Jason Wang
2020-11-24 13:33 ` [PULL 0/5] Net patches Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1606185863-25996-5-git-send-email-jasowang@redhat.com \
    --to=jasowang@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=ruc_gongyuanjun@163.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.