diff options
author | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2012-10-09 18:03:52 +0200 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2012-10-09 18:43:51 +0200 |
commit | bff95e0a02b6fa0b760f3e5b27ae9e712638e007 (patch) | |
tree | 3b833641742f2ed8ea9e0594452c3c9a1b208ff0 /audio | |
parent | d35a363e2c008d050b92cfb50dee21d382438600 (diff) |
audio: Fix memory leak of AVDTP buffer
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.
Diffstat (limited to 'audio')
-rw-r--r-- | audio/sink.c | 8 | ||||
-rw-r--r-- | audio/source.c | 8 |
2 files changed, 16 insertions, 0 deletions
diff --git a/audio/sink.c b/audio/sink.c index 4eb2c618..0628fd24 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 41aedd22..e1119540 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, |