Linux bluetooth development
 help / color / mirror / Atom feed
From: Jakob Stender Guldberg <jakob1379@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: Jakob Stender Guldberg <jakob1379@gmail.com>
Subject: [PATCH BlueZ] avdtp: Fix rejected Close dropping A2DP
Date: Fri,  4 Dec 2026 09:00:44 +0100	[thread overview]
Message-ID: <20261204080044.4151850-1-jakob1379@gmail.com> (raw)

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


                 reply	other threads:[~2026-12-04  8:00 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261204080044.4151850-1-jakob1379@gmail.com \
    --to=jakob1379@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox