* [PATCH] btproxy: Fix resource leak
@ 2014-01-23 9:07 Andrei Emeltchenko
2014-01-23 13:24 ` Johan Hedberg
0 siblings, 1 reply; 5+ messages in thread
From: Andrei Emeltchenko @ 2014-01-23 9:07 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Close file descriptors before leaving.
---
tools/btproxy.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tools/btproxy.c b/tools/btproxy.c
index be81bae..3503148 100644
--- a/tools/btproxy.c
+++ b/tools/btproxy.c
@@ -680,8 +680,11 @@ int main(int argc, char *argv[])
return EXIT_FAILURE;
}
- if (!setup_proxy(host_fd, false, dev_fd, true))
+ if (!setup_proxy(host_fd, false, dev_fd, true)) {
+ close(dev_fd);
+ close(host_fd);
return EXIT_FAILURE;
+ }
} else {
int server_fd;
--
1.8.3.2
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH] btproxy: Fix resource leak
@ 2014-01-22 11:00 Andrei Emeltchenko
2014-01-22 13:52 ` Johan Hedberg
2014-01-22 15:54 ` Marcel Holtmann
0 siblings, 2 replies; 5+ messages in thread
From: Andrei Emeltchenko @ 2014-01-22 11:00 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Close file descriptors if setup_proxy fails.
---
tools/btproxy.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tools/btproxy.c b/tools/btproxy.c
index 4429a16..9f409c3 100644
--- a/tools/btproxy.c
+++ b/tools/btproxy.c
@@ -330,8 +330,11 @@ static bool setup_proxy(int host_fd, bool host_shutdown,
struct proxy *proxy;
proxy = new0(struct proxy, 1);
- if (!proxy)
+ if (!proxy) {
+ close(host_fd);
+ close(dev_fd);
return NULL;
+ }
proxy->host_fd = host_fd;
proxy->host_shutdown = host_shutdown;
--
1.8.3.2
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] btproxy: Fix resource leak
2014-01-22 11:00 Andrei Emeltchenko
@ 2014-01-22 13:52 ` Johan Hedberg
2014-01-22 15:54 ` Marcel Holtmann
1 sibling, 0 replies; 5+ messages in thread
From: Johan Hedberg @ 2014-01-22 13:52 UTC (permalink / raw)
To: Andrei Emeltchenko; +Cc: linux-bluetooth
Hi Andrei,
On Wed, Jan 22, 2014, Andrei Emeltchenko wrote:
> Close file descriptors if setup_proxy fails.
> ---
> tools/btproxy.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
Applied. Thanks.
Johan
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] btproxy: Fix resource leak
2014-01-22 11:00 Andrei Emeltchenko
2014-01-22 13:52 ` Johan Hedberg
@ 2014-01-22 15:54 ` Marcel Holtmann
1 sibling, 0 replies; 5+ messages in thread
From: Marcel Holtmann @ 2014-01-22 15:54 UTC (permalink / raw)
To: Andrei Emeltchenko; +Cc: linux-bluetooth@vger.kernel.org development
Hi Andrei,
> Close file descriptors if setup_proxy fails.
> ---
> tools/btproxy.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/tools/btproxy.c b/tools/btproxy.c
> index 4429a16..9f409c3 100644
> --- a/tools/btproxy.c
> +++ b/tools/btproxy.c
> @@ -330,8 +330,11 @@ static bool setup_proxy(int host_fd, bool host_shutdown,
> struct proxy *proxy;
>
> proxy = new0(struct proxy, 1);
> - if (!proxy)
> + if (!proxy) {
> + close(host_fd);
> + close(dev_fd);
> return NULL;
> + }
this is the wrong fix for this.
You are returning an error with side effects of closing the file descriptors. You need to leave the error handling of the parameters that got handed in to the caller. I fixed that upstream now.
Regards
Marcel
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-01-23 13:24 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-23 9:07 [PATCH] btproxy: Fix resource leak Andrei Emeltchenko
2014-01-23 13:24 ` Johan Hedberg
-- strict thread matches above, loose matches on Subject: below --
2014-01-22 11:00 Andrei Emeltchenko
2014-01-22 13:52 ` Johan Hedberg
2014-01-22 15:54 ` Marcel Holtmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox