Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH BlueZ] avdtp: Fix rejected Close dropping A2DP
@ 2026-12-04  8:00 Jakob Stender Guldberg
  0 siblings, 0 replies; only message in thread
From: Jakob Stender Guldberg @ 2026-12-04  8:00 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jakob Stender Guldberg

A Close Reject carries only the Error Code, but avdtp_parse_rej() parsed
it with stream_rej_to_err(), which wants an ACP SEID before it. The
1 byte reject failed the size check and session_cb() dropped the whole
session.

OnePlus Buds Pro 4 often reject Close with BAD_ACP_SEID, so changing the
codec left the headset without A2DP:

  < 80 08 08
  > 83 08 12
  stream_rej_to_err() Too small packet for stream_rej
  session_cb() Unable to parse reject response

Parse the Error Code alone and release the stream as if the Close had
been accepted.

Fixes: 6763ebb3c231 ("Integrate A2DP work from Johan's and Luiz's GIT trees")
Assisted-by: Claude:claude-opus-5-5
---
Tests:
- A test program runs a2dp.c and avdtp.c against simulated buds that
  reject Close. The codec change fails on master and works with this
  patch. The test program is not in the tree.
- On real OnePlus Buds Pro 4 with BlueZ 5.87, the codec changed from AAC
  to SBC and back. The buds rejected both Close commands. That build also
  contained a change to a2dp.c that is not in this patch.
- make check gives the same result with and without this patch.

The BlueZ tree has no test for this case. The functional tests have no
remote device that rejects Close.

 profiles/audio/avdtp.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c
index c49ac9c0e..191ae12b5 100644
--- a/profiles/audio/avdtp.c
+++ b/profiles/audio/avdtp.c
@@ -3192,15 +3192,12 @@ static gboolean avdtp_parse_rej(struct avdtp *session,
 						sep->user_data);
 		return TRUE;
 	case AVDTP_CLOSE:
-		if (!stream_rej_to_err(buf, size, &err, &acp_seid))
+		if (!seid_rej_to_err(buf, size, &err))
 			return FALSE;
 		error("CLOSE request rejected: %s (%d)",
 				avdtp_strerror(&err), err.err.error_code);
-		if (sep && sep->cfm && sep->cfm->close) {
-			sep->cfm->close(session, sep, stream, &err,
-					sep->user_data);
-			stream->close_int = FALSE;
-		}
+		if (stream)
+			return avdtp_close_resp(session, stream, buf, size);
 		return TRUE;
 	case AVDTP_ABORT:
 		if (!stream_rej_to_err(buf, size, &err, &acp_seid))

base-commit: 71f224fd62317779ec6de23098b4dd96ea83ae5e
-- 
2.56.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-12-04  8:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04  8:00 [PATCH BlueZ] avdtp: Fix rejected Close dropping A2DP Jakob Stender Guldberg

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