Skip to contentSkip to conversation

shared/bap: Fix handling of ASCS_Codec_Config

PATCH In review Luiz Augusto von Dentz 2 participants 2 messages May 5, 2025 Bluetooth drivers

lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH 1/1 shared/bap: Fix handling of ASCS_Codec_Config

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

The codec under bt_ascs_config is in little endian which may differ from the native endianness when it comes to vendor specific field that are multibyte causing the following error:

BAP/USR/SCC/BV-033-C [USR SNK Config Codec, VS] - setup complete BAP/USR/SCC/BV-033-C [USR SNK Config Codec, VS] - run
...
bt_gatt_server:src/shared/gatt-server.c:write_cb() Write Cmd - handle: 0x0022 bt_bap:src/shared/bap.c:ascs_ase_cp_write() Codec Config bt_bap:src/shared/bap.c:ascs_config() codec 0xff phy 0x02 latency 2 bt_bap:src/shared/bap.c:ep_config() ep 0x21d6600 id 0x01 dir 0x01 handle 0x0022 len 5
test-bap: > 1b 22 00 01 01 01 09 01 ."......
test-bap: ! 1b 22 00 01 01 01 00 00 ."......

---
 src/shared/bap.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
src/shared/bap.c +8 -1
index 2a08f3eea7b8..ca3a9e5c3a36 100644
@@ -2975,6 +2975,7 @@ static uint8_t ep_config(struct bt_bap_endpoint *ep, struct bt_bap *bap,
 {
 	struct iovec cc;
 	const struct queue_entry *e;
+	struct bt_bap_codec codec;
 
 	DBG(bap, "ep %p id 0x%02x dir 0x%02x", ep, ep->id, ep->dir);
 
@@ -3019,10 +3020,16 @@ static uint8_t ep_config(struct bt_bap_endpoint *ep, struct bt_bap *bap,
 		e = NULL;
 	}
 
+	/* Convert to native endianness before comparing */
+	memset(&codec, 0, sizeof(codec));
+	codec.id = req->codec.id;
+	codec.cid = le16_to_cpu(req->codec.cid);
+	codec.vid = le16_to_cpu(req->codec.vid);
+
 	for (; e; e = e->next) {
 		struct bt_bap_pac *pac = e->data;
 
-		if (!bap_codec_equal(&req->codec, &pac->codec))
+		if (!bap_codec_equal(&codec, &pac->codec))
 			continue;
 
 		if (!ep->stream)
Signature · 1 line
2.49.0
#1 lore raw

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=959755

---Test result---

Test Summary:

CheckPatch                    PENDING   0.30 seconds
GitLint                       PENDING   0.27 seconds
BuildEll                      PASS      20.70 seconds
BluezMake                     PASS      2872.27 seconds
MakeCheck                     PASS      20.90 seconds
MakeDistcheck                 PASS      205.69 seconds
CheckValgrind                 PASS      284.64 seconds
CheckSmatch                   WARNING   310.23 seconds
bluezmakeextell               PASS      132.14 seconds
IncrementalBuild              PENDING   0.27 seconds
ScanBuild                     PASS      939.96 seconds

Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script Output:

##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:

##############################
Test: CheckSmatch - WARNING
Desc: Run smatch tool with source
Output:
src/shared/bap.c:315:25: warning: array of flexible structuressrc/shared/bap.c: note: in included file:./src/shared/ascs.h:88:25: warning: array of flexible structuressrc/shared/bap.c:315:25: warning: array of flexible structuressrc/shared/bap.c: note: in included file:./src/shared/ascs.h:88:25: warning: array of flexible structuressrc/shared/bap.c:315:25: warning: array of flexible structuressrc/shared/bap.c: note: in included file:./src/shared/ascs.h:88:25: warning: array of flexible structures
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:

---
Regards,
Linux Bluetooth