qemu-trivial
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-trivial] [PULL 22/23] tap: fix possible fd leak in net_init_tap


From: Michael Tokarev
Subject: [Qemu-trivial] [PULL 22/23] tap: fix possible fd leak in net_init_tap
Date: Sun, 2 Nov 2014 14:57:34 +0300

From: Gonglei <address@hidden>

In hotplugging scenario, taking those true branch, the file
handler do not be closed. Let's close them before return.

Signed-off-by: Gonglei <address@hidden>
Signed-off-by: Michael Tokarev <address@hidden>
---
 net/tap.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/tap.c b/net/tap.c
index 7bcd4c7..bde6b58 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -796,6 +796,7 @@ int net_init_tap(const NetClientOptions *opts, const char 
*name,
         if (net_init_tap_one(tap, peer, "bridge", name, ifname,
                              script, downscript, vhostfdname,
                              vnet_hdr, fd)) {
+            close(fd);
             return -1;
         }
     } else {
@@ -823,6 +824,7 @@ int net_init_tap(const NetClientOptions *opts, const char 
*name,
             if (queues > 1 && i == 0 && !tap->has_ifname) {
                 if (tap_fd_get_ifname(fd, ifname)) {
                     error_report("Fail to get ifname");
+                    close(fd);
                     return -1;
                 }
             }
@@ -831,6 +833,7 @@ int net_init_tap(const NetClientOptions *opts, const char 
*name,
                                  i >= 1 ? "no" : script,
                                  i >= 1 ? "no" : downscript,
                                  vhostfdname, vnet_hdr, fd)) {
+                close(fd);
                 return -1;
             }
         }
-- 
1.7.10.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]