All of lore.kernel.org
 help / color / mirror / Atom feed
From: ruc_gongyuanjun@163.com
To: Jason Wang <jasowang@redhat.com>, qemu-devel@nongnu.org
Cc: yuanjungong <ruc_gongyuanjun@163.com>
Subject: [PATCH 1/1] net/socket.c: Fix memory leak
Date: Wed,  9 Dec 2020 20:00:13 +0800	[thread overview]
Message-ID: <20201209120013.13317-1-ruc_gongyuanjun@163.com> (raw)

From: yuanjungong <ruc_gongyuanjun@163.com>

close fd opened by monitor_fd_param() before returning.

Signed-off-by: yuanjungong <ruc_gongyuanjun@163.com>
---
 net/socket.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/socket.c b/net/socket.c
index 15b410e..2f720a7 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -735,12 +735,15 @@ int net_init_socket(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;
         }
         if (!net_socket_fd_init(peer, "socket", name, fd, 1, sock->mcast,
                                 errp)) {
+            close(fd);
             return -1;
         }
+        close(fd);
         return 0;
     }
 
-- 
2.17.1



             reply	other threads:[~2020-12-09 12:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-09 12:00 ruc_gongyuanjun [this message]
2020-12-10  8:51 ` [PATCH 1/1] net/socket.c: Fix memory leak Stefano Garzarella

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=20201209120013.13317-1-ruc_gongyuanjun@163.com \
    --to=ruc_gongyuanjun@163.com \
    --cc=jasowang@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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.