qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: yuanjungong <1904486@bugs.launchpad.net>
To: qemu-devel@nongnu.org
Subject: [Bug 1904486] [NEW] resource leak in /net/tap.c
Date: Tue, 17 Nov 2020 02:15:23 -0000	[thread overview]
Message-ID: <160557932327.14164.11613670931205353723.malonedeb@soybean.canonical.com> (raw)

Public bug reported:

Hi,there might be a resource leak in function net_init_tap in
/net/tap.c.

 811         fd = monitor_fd_param(monitor_cur(), tap->fd, errp);
 812         if (fd == -1) {
 813             return -1;
 814         }
 815 
 816         ret = qemu_try_set_nonblock(fd);
 817         if (ret < 0) {
 818             error_setg_errno(errp, -ret, "%s: Can't use file descriptor %d",
 819                              name, fd);
 820             return -1;
 821         }
 822 
 823         vnet_hdr = tap_probe_vnet_hdr(fd, errp);
 824         if (vnet_hdr < 0) {
 825             close(fd);
 826             return -1;
 827         }
 828 
 829         net_init_tap_one(tap, peer, "tap", name, NULL,
 830                          script, downscript,
 831                          vhostfdname, vnet_hdr, fd, &err);
 832         if (err) {
 833             error_propagate(errp, err);
 834             return -1;
 835         }

fd should be closed before return in line 820 and line 834, similar to
the implementation in line 825.

** Affects: qemu
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1904486

Title:
  resource leak in /net/tap.c

Status in QEMU:
  New

Bug description:
  Hi,there might be a resource leak in function net_init_tap in
  /net/tap.c.

   811         fd = monitor_fd_param(monitor_cur(), tap->fd, errp);
   812         if (fd == -1) {
   813             return -1;
   814         }
   815 
   816         ret = qemu_try_set_nonblock(fd);
   817         if (ret < 0) {
   818             error_setg_errno(errp, -ret, "%s: Can't use file descriptor %d",
   819                              name, fd);
   820             return -1;
   821         }
   822 
   823         vnet_hdr = tap_probe_vnet_hdr(fd, errp);
   824         if (vnet_hdr < 0) {
   825             close(fd);
   826             return -1;
   827         }
   828 
   829         net_init_tap_one(tap, peer, "tap", name, NULL,
   830                          script, downscript,
   831                          vhostfdname, vnet_hdr, fd, &err);
   832         if (err) {
   833             error_propagate(errp, err);
   834             return -1;
   835         }

  fd should be closed before return in line 820 and line 834, similar to
  the implementation in line 825.

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1904486/+subscriptions


             reply	other threads:[~2020-11-17  2:21 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-17  2:15 yuanjungong [this message]
2020-11-17  6:08 ` [Bug 1904486] Re: resource leak in /net/tap.c yuanjungong
2020-11-17 10:26 ` Alex Chen
2020-11-20  1:57 ` Alex Chen
2020-11-20  2:16 ` yuanjungong
2020-11-20  2:35 ` yuanjungong
2020-11-21 23:37 ` Peter Maydell
2020-12-01 13:05 ` Peter Maydell
2020-12-10  8:49 ` Thomas Huth

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=160557932327.14164.11613670931205353723.malonedeb@soybean.canonical.com \
    --to=1904486@bugs.launchpad.net \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).