Skip to contentSkip to conversation

avdtp: Fix not checking if stream is already set as pending open

PATCH In review Luiz Augusto von Dentz 1 participant 2 messages Sep 18, 2020 – Sep 21, 2020 Bluetooth drivers

lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH v2 1/1 avdtp: Fix not checking if stream is already set as pending open

From: Luiz Augusto von Dentz <[email protected]>

When receiving a Open command the stream will be set as pending_open but the remote may attempt to send yet another Open command in the meantime resulting in another setup and yet another timer leaving the old timer active which will likely cause a crash when it expires.

---
 profiles/audio/avdtp.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
profiles/audio/avdtp.c +6 -4
index 782268c08..e0c6f44f0 100644
@@ -1687,7 +1687,7 @@ static gboolean avdtp_open_cmd(struct avdtp *session, uint8_t transaction,
 
 	stream = sep->stream;
 
-	if (sep->ind && sep->ind->open) {
+	if (sep->ind && sep->ind->open && !session->pending_open) {
 		if (!sep->ind->open(session, sep, stream, &err,
 					sep->user_data))
 			goto failed;
@@ -1699,11 +1699,13 @@ static gboolean avdtp_open_cmd(struct avdtp *session, uint8_t transaction,
 						AVDTP_OPEN, NULL, 0))
 		return FALSE;
 
-	stream->open_acp = TRUE;
-	session->pending_open = stream;
-	stream->timer = g_timeout_add_seconds(REQ_TIMEOUT,
+	if (!session->pending_open) {
+		stream->open_acp = TRUE;
+		session->pending_open = stream;
+		stream->timer = g_timeout_add_seconds(REQ_TIMEOUT,
 						stream_open_timeout,
 						stream);
+	}
 
 	return TRUE;
 
Signature · 1 line
2.26.2
author maintainer
#1 lore raw

Hi,

Quoted 42 lines · Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

When receiving a Open command the stream will be set as pending_open but the remote may attempt to send yet another Open command in the meantime resulting in another setup and yet another timer leaving the old timer active which will likely cause a crash when it expires.

---
 profiles/audio/avdtp.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
profiles/audio/avdtp.c +6 -5
index 782268c08..e0c6f44f0 100644
@@ -1687,7 +1687,7 @@ static gboolean avdtp_open_cmd(struct avdtp *session, uint8_t transaction,
 
        stream = sep->stream;
 
-       if (sep->ind && sep->ind->open) {
+       if (sep->ind && sep->ind->open && !session->pending_open) {
                if (!sep->ind->open(session, sep, stream, &err,
                                        sep->user_data))
                        goto failed;
@@ -1699,11 +1699,13 @@ static gboolean avdtp_open_cmd(struct avdtp *session, uint8_t transaction,
                                                AVDTP_OPEN, NULL, 0))
                return FALSE;
 
-       stream->open_acp = TRUE;
-       session->pending_open = stream;
-       stream->timer = g_timeout_add_seconds(REQ_TIMEOUT,
+       if (!session->pending_open) {
+               stream->open_acp = TRUE;
+               session->pending_open = stream;
+               stream->timer = g_timeout_add_seconds(REQ_TIMEOUT,
                                                stream_open_timeout,
                                                stream);
+       }
 
        return TRUE;
 
--
Quoted 1 line

2.26.2

Pushed.

Signature · 1 line
Luiz Augusto von Dentz