Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH BlueZ 1/2] audio: Fix memory leak of AVDTP buffer
@ 2012-10-09 16:03 Luiz Augusto von Dentz
  2012-10-09 16:03 ` [PATCH BlueZ 2/2] sink: Remove deprecated code Luiz Augusto von Dentz
  2012-10-09 16:44 ` [PATCH BlueZ 1/2] audio: Fix memory leak of AVDTP buffer Johan Hedberg
  0 siblings, 2 replies; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2012-10-09 16:03 UTC (permalink / raw)
  To: linux-bluetooth

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

Upon disconnection all references to AVDTP session should be release
otherwise the data associate with it cannot be freed and new connection
may overwrite the buf pointer causing it to leak.
---
 audio/sink.c   | 8 ++++++++
 audio/source.c | 8 ++++++++
 2 files changed, 16 insertions(+)

diff --git a/audio/sink.c b/audio/sink.c
index 4eb2c61..0628fd2 100644
--- a/audio/sink.c
+++ b/audio/sink.c
@@ -125,6 +125,14 @@ static void sink_set_state(struct audio_device *dev, sink_state_t new_state)
 		struct sink_state_callback *cb = l->data;
 		cb->cb(dev, old_state, new_state, cb->user_data);
 	}
+
+	if (new_state != SINK_STATE_DISCONNECTED)
+		return;
+
+	if (sink->session) {
+		avdtp_unref(sink->session);
+		sink->session = NULL;
+	}
 }
 
 static void avdtp_state_callback(struct audio_device *dev,
diff --git a/audio/source.c b/audio/source.c
index 41aedd2..e111954 100644
--- a/audio/source.c
+++ b/audio/source.c
@@ -116,6 +116,14 @@ static void source_set_state(struct audio_device *dev, source_state_t new_state)
 		struct source_state_callback *cb = l->data;
 		cb->cb(dev, old_state, new_state, cb->user_data);
 	}
+
+	if (new_state != SOURCE_STATE_DISCONNECTED)
+		return;
+
+	if (source->session) {
+		avdtp_unref(source->session);
+		source->session = NULL;
+	}
 }
 
 static void avdtp_state_callback(struct audio_device *dev,
-- 
1.7.11.4


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

end of thread, other threads:[~2012-10-09 16:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-09 16:03 [PATCH BlueZ 1/2] audio: Fix memory leak of AVDTP buffer Luiz Augusto von Dentz
2012-10-09 16:03 ` [PATCH BlueZ 2/2] sink: Remove deprecated code Luiz Augusto von Dentz
2012-10-09 16:44 ` [PATCH BlueZ 1/2] audio: Fix memory leak of AVDTP buffer Johan Hedberg

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