* [Qemu-trivial] [PATCH v2] tap: fix possible fd leak in net_init_tap
@ 2014-11-02 5:37 ` arei.gonglei
0 siblings, 0 replies; 6+ messages in thread
From: arei.gonglei @ 2014-11-02 5:37 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Gonglei, mjt, peter.huangpeng, stefanha
From: Gonglei <arei.gonglei@huawei.com>
In hotplugging scenario, taking those true branch, the file
handler do not be closed. Let's close them before return.
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
v1: [PATCH 2/2] tap: fix possible fd leak
v2: add explicit close(fd) and change subject. (Thanks to /mjt)
---
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.12.4
^ permalink raw reply related [flat|nested] 6+ messages in thread* [Qemu-devel] [PATCH v2] tap: fix possible fd leak in net_init_tap
@ 2014-11-02 5:37 ` arei.gonglei
0 siblings, 0 replies; 6+ messages in thread
From: arei.gonglei @ 2014-11-02 5:37 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Gonglei, mjt, peter.huangpeng, stefanha
From: Gonglei <arei.gonglei@huawei.com>
In hotplugging scenario, taking those true branch, the file
handler do not be closed. Let's close them before return.
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
v1: [PATCH 2/2] tap: fix possible fd leak
v2: add explicit close(fd) and change subject. (Thanks to /mjt)
---
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.12.4
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [Qemu-trivial] [PATCH v2] tap: fix possible fd leak in net_init_tap
2014-11-02 5:37 ` [Qemu-devel] " arei.gonglei
@ 2014-11-02 5:39 ` Michael Tokarev
-1 siblings, 0 replies; 6+ messages in thread
From: Michael Tokarev @ 2014-11-02 5:39 UTC (permalink / raw)
To: arei.gonglei, qemu-devel; +Cc: qemu-trivial, peter.huangpeng, stefanha
02.11.2014 08:37, arei.gonglei@huawei.com wrote:
>
> In hotplugging scenario, taking those true branch, the file
> handler do not be closed. Let's close them before return.
This looks much better now, and is shorter too :)
Applied to -trivial, thank you!
/mjt
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH v2] tap: fix possible fd leak in net_init_tap
@ 2014-11-02 5:39 ` Michael Tokarev
0 siblings, 0 replies; 6+ messages in thread
From: Michael Tokarev @ 2014-11-02 5:39 UTC (permalink / raw)
To: arei.gonglei, qemu-devel; +Cc: qemu-trivial, peter.huangpeng, stefanha
02.11.2014 08:37, arei.gonglei@huawei.com wrote:
>
> In hotplugging scenario, taking those true branch, the file
> handler do not be closed. Let's close them before return.
This looks much better now, and is shorter too :)
Applied to -trivial, thank you!
/mjt
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-trivial] [PATCH v2] tap: fix possible fd leak in net_init_tap
2014-11-02 5:39 ` [Qemu-devel] " Michael Tokarev
@ 2014-11-02 5:51 ` Gonglei
-1 siblings, 0 replies; 6+ messages in thread
From: Gonglei @ 2014-11-02 5:51 UTC (permalink / raw)
To: Michael Tokarev
Cc: qemu-trivial@nongnu.org, qemu-devel@nongnu.org,
stefanha@redhat.com, Huangpeng (Peter)
On 2014/11/2 13:39, Michael Tokarev wrote:
> 02.11.2014 08:37, arei.gonglei@huawei.com wrote:
>>
>> In hotplugging scenario, taking those true branch, the file
>> handler do not be closed. Let's close them before return.
>
> This looks much better now, and is shorter too :)
> Applied to -trivial, thank you!
>
Thanks :)
Best regards,
-Gonglei
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH v2] tap: fix possible fd leak in net_init_tap
@ 2014-11-02 5:51 ` Gonglei
0 siblings, 0 replies; 6+ messages in thread
From: Gonglei @ 2014-11-02 5:51 UTC (permalink / raw)
To: Michael Tokarev
Cc: qemu-trivial@nongnu.org, qemu-devel@nongnu.org,
stefanha@redhat.com, Huangpeng (Peter)
On 2014/11/2 13:39, Michael Tokarev wrote:
> 02.11.2014 08:37, arei.gonglei@huawei.com wrote:
>>
>> In hotplugging scenario, taking those true branch, the file
>> handler do not be closed. Let's close them before return.
>
> This looks much better now, and is shorter too :)
> Applied to -trivial, thank you!
>
Thanks :)
Best regards,
-Gonglei
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-11-02 5:52 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-02 5:37 [Qemu-trivial] [PATCH v2] tap: fix possible fd leak in net_init_tap arei.gonglei
2014-11-02 5:37 ` [Qemu-devel] " arei.gonglei
2014-11-02 5:39 ` [Qemu-trivial] " Michael Tokarev
2014-11-02 5:39 ` [Qemu-devel] " Michael Tokarev
2014-11-02 5:51 ` [Qemu-trivial] " Gonglei
2014-11-02 5:51 ` [Qemu-devel] " Gonglei
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.