* [PATCH 1/2 v2] Fix memory leak when calling endpoint method
@ 2011-01-11 12:21 Luiz Augusto von Dentz
2011-01-11 20:13 ` Johan Hedberg
0 siblings, 1 reply; 2+ messages in thread
From: Luiz Augusto von Dentz @ 2011-01-11 12:21 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..402709a 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_cancel(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
* Re: [PATCH 1/2 v2] Fix memory leak when calling endpoint method
2011-01-11 12:21 [PATCH 1/2 v2] Fix memory leak when calling endpoint method Luiz Augusto von Dentz
@ 2011-01-11 20:13 ` Johan Hedberg
0 siblings, 0 replies; 2+ messages in thread
From: Johan Hedberg @ 2011-01-11 20:13 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
Hi Luiz,
On Tue, Jan 11, 2011, Luiz Augusto von Dentz wrote:
> 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(-)
Both patches have been pushed upstream. Thanks.
Johan
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-01-11 20:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-11 12:21 [PATCH 1/2 v2] Fix memory leak when calling endpoint method Luiz Augusto von Dentz
2011-01-11 20:13 ` Johan Hedberg
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.