Fix stream handling when the media transport disconnects prematurely
We might not have a stream anymore when receiving the reply to a AVDTP
command that assumes that there is an existing stream. So ignore the
replies to these commands if we don't have a stream anymore.
diff --git a/audio/avdtp.c b/audio/avdtp.c
index 2a27ac8..efc001d 100644
--- a/audio/avdtp.c
+++ b/audio/avdtp.c
@@ -2580,6 +2580,16 @@
if (!(next && next->signal_id == AVDTP_GET_CAPABILITIES))
finalize_discovery(session, 0);
return TRUE;
+ }
+
+ /* The remaining commands require an existing stream so bail out
+ * here if the stream got unexpectedly disconnected */
+ if (!stream) {
+ debug("AVDTP: stream was closed while waiting for reply");
+ return TRUE;
+ }
+
+ switch (signal_id) {
case AVDTP_SET_CONFIGURATION:
debug("SET_CONFIGURATION request succeeded");
return avdtp_set_configuration_resp(session, stream,