Skip to contentSkip to conversation

audio/AVCTP: Fix sending requests with same transaction id

PATCH Applied Luiz Augusto von Dentz 2 participants 2 messages Oct 14, 2013 – Oct 15, 2013 Bluetooth drivers

lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH 1/1 audio/AVCTP: Fix sending requests with same transaction id

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

If a request is outstanding in the processed list its transaction shall not be reused as it can cause the wrong callback to be called.

This can be reproduced in very rare occasions where e.g. a notification using the same transaction of the current request arrives before the response itself.

---
 profiles/audio/avctp.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
profiles/audio/avctp.c +21 -0
index 845027f..dac7a66 100644
@@ -1480,7 +1480,28 @@ static struct avctp_pending_req *pending_create(struct avctp_channel *chan,
 						GDestroyNotify destroy)
 {
 	struct avctp_pending_req *p;
+	GSList *l, *tmp;
 
+	if (!chan->processed)
+		goto done;
+
+	tmp = g_slist_copy(chan->processed);
+
+	/* Find first unused transaction id */
+	for (l = tmp; l; l = l->next) {
+		struct avctp_pending_req *req = l->data;
+
+		if (req->transaction == chan->transaction) {
+			chan->transaction++;
+			chan->transaction %= 16;
+			tmp = g_slist_delete_link(tmp, l);
+			l = tmp;
+		}
+	}
+
+	g_slist_free(tmp);
+
+done:
 	p = g_new0(struct avctp_pending_req, 1);
 	p->chan = chan;
 	p->transaction = chan->transaction;
Signature · 1 line
1.8.3.1
#1 lore raw

Hi Luiz,

Quoted 9 lines · Luiz Augusto von Dentz

If a request is outstanding in the processed list its transaction shall not be reused as it can cause the wrong callback to be called.

This can be reproduced in very rare occasions where e.g. a notification using the same transaction of the current request arrives before the response itself.

---
 profiles/audio/avctp.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

Applied. Thanks.

Johan