Linux bluetooth development
 help / color / mirror / Atom feed
* [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
* [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

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-22 11:00 [PATCH] btproxy: Fix resource leak Andrei Emeltchenko
2014-01-22 13:52 ` Johan Hedberg
2014-01-22 15:54 ` Marcel Holtmann
  -- strict thread matches above, loose matches on Subject: below --
2014-01-23  9:07 Andrei Emeltchenko
2014-01-23 13:24 ` Johan Hedberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox