linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] Fix memory leak when calling endpoint method
@ 2011-01-11 11:54 Luiz Augusto von Dentz
  2011-01-11 11:54 ` [PATCH 2/2] Fix possible memory leak when handling avdtp transport connection Luiz Augusto von Dentz
  0 siblings, 1 reply; 2+ messages in thread
From: Luiz Augusto von Dentz @ 2011-01-11 11:54 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.dentz-von@nokia.com>

The pending call must be unrefed in those cases
---
 audio/media.c |   21 +++++++++++++++------
 1 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/audio/media.c b/audio/media.c
index 97a60a1..03647f5 100644
--- a/audio/media.c
+++ b/audio/media.c
@@ -87,12 +87,23 @@ static GSList *adapters = NULL;
 static void endpoint_request_free(struct endpoint_request *request)
 {
 	if (request->call)
-		dbus_pending_call_cancel(request->call);
+		dbus_pending_call_unref(request->call);
 
 	dbus_message_unref(request->msg);
 	g_free(request);
 }
 
+static void media_endpoint_cancel(struct media_endpoint *endpoint)
+{
+	struct endpoint_request *request = endpoint->request;
+
+	if (request->call)
+		dbus_pending_call_unref(request->call);
+
+	endpoint_request_free(request);
+	endpoint->request = NULL;
+}
+
 static void media_endpoint_remove(struct media_endpoint *endpoint)
 {
 	struct media_adapter *adapter = endpoint->adapter;
@@ -109,7 +120,7 @@ static void media_endpoint_remove(struct media_endpoint *endpoint)
 		headset_remove_state_cb(endpoint->hs_watch);
 
 	if (endpoint->request)
-		endpoint_request_free(endpoint->request);
+		media_endpoint_cancel(endpoint);
 
 	if (endpoint->transport)
 		media_transport_remove(endpoint->transport);
@@ -613,10 +624,8 @@ void media_endpoint_clear_configuration(struct media_endpoint *endpoint)
 	if (endpoint->transport == NULL)
 		return;
 
-	if (endpoint->request) {
-		endpoint_request_free(endpoint->request);
-		endpoint->request = NULL;
-	}
+	if (endpoint->request)
+		media_endpoint_cancel(endpoint);
 
 	conn = endpoint->adapter->conn;
 
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH 2/2] Fix possible memory leak when handling avdtp transport connection
  2011-01-11 11:54 [PATCH 1/2] Fix memory leak when calling endpoint method Luiz Augusto von Dentz
@ 2011-01-11 11:54 ` Luiz Augusto von Dentz
  0 siblings, 0 replies; 2+ messages in thread
From: Luiz Augusto von Dentz @ 2011-01-11 11:54 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.dentz-von@nokia.com>

When acting as initiator stream io already has a reference to io channel
to be able to cancel if necessary.
---
 audio/avdtp.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/audio/avdtp.c b/audio/avdtp.c
index 0d50627..fdac1e3 100644
--- a/audio/avdtp.c
+++ b/audio/avdtp.c
@@ -895,7 +895,9 @@ static void handle_transport_connect(struct avdtp *session, GIOChannel *io,
 		return;
 	}
 
-	stream->io = g_io_channel_ref(io);
+	if (stream->io == NULL)
+		stream->io = g_io_channel_ref(io);
+
 	stream->omtu = omtu;
 	stream->imtu = imtu;
 
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-01-11 11:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-11 11:54 [PATCH 1/2] Fix memory leak when calling endpoint method Luiz Augusto von Dentz
2011-01-11 11:54 ` [PATCH 2/2] Fix possible memory leak when handling avdtp transport connection Luiz Augusto von Dentz

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).