diff mbox series

[BlueZ,1/5] shared/bap: Fix handling for Company ID and Vendor Codec ID

Message ID 20221029170408.175533-2-abhay.maheshbhai.maheta@intel.com (mailing list archive)
State New, archived
Headers show
Series To add support for Metadata, CID, VID | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/checkpatch success Checkpatch PASS
tedd_an/gitlint success Gitlint PASS
tedd_an/setupell success Setup ELL PASS
tedd_an/buildprep success Build Prep PASS
tedd_an/build success Build Configuration PASS
tedd_an/makecheck success Make Check PASS
tedd_an/makecheckvalgrind success Make Check PASS
tedd_an/makedistcheck success Make Distcheck PASS
tedd_an/build_extell success Build External ELL PASS
tedd_an/build_extell_make success Build Make with External ELL PASS
tedd_an/incremental_build success Pass
tedd_an/scan_build warning Scan-Build: client/player.c:1770:25: warning: Dereference of null pointer iov_append(&cfg->caps, preset->data.iov_base, preset->data.iov_len); ^~~~~~~~~~~~~~~~~~~~~ 1 warning generated. profiles/audio/media.c:1159:3: warning: Potential leak of memory pointed to by 'metadata' error("Could not allocate name for pac %s:%s", ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ./src/log.h:62:2: note: expanded from macro 'error' btd_error(0xffff, "%s:%s() " fmt, __FILE__, __func__, ## arg) ^~~~~~~~~ 1 warning generated.

Commit Message

Abhay Maheta Oct. 29, 2022, 5:04 p.m. UTC
This adds fixes for handing for Company ID and Vendor Codec ID
while adding PAC record to database and responding to Attribute
Read Request for Sink/Source PAC Characteristics.
---
 src/shared/bap.c | 5 +++++
 src/shared/bap.h | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

Comments

bluez.test.bot@gmail.com Oct. 29, 2022, 5:42 p.m. UTC | #1
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=690159

---Test result---

Test Summary:
CheckPatch                    PASS      5.60 seconds
GitLint                       PASS      3.64 seconds
Prep - Setup ELL              PASS      26.71 seconds
Build - Prep                  PASS      0.68 seconds
Build - Configure             PASS      8.32 seconds
Build - Make                  PASS      749.65 seconds
Make Check                    PASS      11.86 seconds
Make Check w/Valgrind         PASS      292.31 seconds
Make Distcheck                PASS      240.14 seconds
Build w/ext ELL - Configure   PASS      8.38 seconds
Build w/ext ELL - Make        PASS      85.77 seconds
Incremental Build w/ patches  PASS      503.62 seconds
Scan Build                    WARNING   547.38 seconds

Details
##############################
Test: Scan Build - WARNING
Desc: Run Scan Build with patches
Output:
*****************************************************************************
The bugs reported by the scan-build may or may not be caused by your patches.
Please check the list and fix the bugs if they are caused by your patch.
*****************************************************************************
client/player.c:1770:25: warning: Dereference of null pointer
        iov_append(&cfg->caps, preset->data.iov_base, preset->data.iov_len);
                               ^~~~~~~~~~~~~~~~~~~~~
1 warning generated.
profiles/audio/media.c:1159:3: warning: Potential leak of memory pointed to by 'metadata'
                error("Could not allocate name for pac %s:%s",
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./src/log.h:62:2: note: expanded from macro 'error'
        btd_error(0xffff, "%s:%s() " fmt, __FILE__, __func__, ## arg)
        ^~~~~~~~~
1 warning generated.




---
Regards,
Linux Bluetooth
Luiz Augusto von Dentz Oct. 31, 2022, 8:48 p.m. UTC | #2
Hi Abhay,

On Sat, Oct 29, 2022 at 9:53 AM Abhay Maheta
<abhay.maheshbhai.maheta@intel.com> wrote:
>
> This adds fixes for handing for Company ID and Vendor Codec ID
> while adding PAC record to database and responding to Attribute
> Read Request for Sink/Source PAC Characteristics.
> ---
>  src/shared/bap.c | 5 +++++
>  src/shared/bap.h | 2 +-
>  2 files changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/src/shared/bap.c b/src/shared/bap.c
> index c3c0d596f..0ae0eba33 100644
> --- a/src/shared/bap.c
> +++ b/src/shared/bap.c
> @@ -416,6 +416,8 @@ static void pac_foreach(void *data, void *user_data)
>
>         p = iov_add(iov, sizeof(*p));
>         p->codec.id = pac->codec.id;

Lets check if the codec.id is 0xff before attempting to assign these
values, btw since they are le16 we need to use cpu_to_le16 when
assigning.

> +       p->codec.cid = pac->codec.cid;
> +       p->codec.vid = pac->codec.vid;
>
>         if (pac->data) {
>                 p->cc_len = pac->data->iov_len;
> @@ -2415,6 +2417,9 @@ struct bt_bap_pac *bt_bap_add_vendor_pac(struct gatt_db *db,
>         if (!bdb)
>                 return NULL;
>
> +       if ((id != 0xff) && ((cid != 0U)  || (vid != 0U)))
> +               return NULL;
> +
>         codec.id = id;
>         codec.cid = cid;
>         codec.vid = vid;
> diff --git a/src/shared/bap.h b/src/shared/bap.h
> index 7b9f88c83..923669f32 100644
> --- a/src/shared/bap.h
> +++ b/src/shared/bap.h
> @@ -39,8 +39,8 @@ struct bt_bap_stream;
>
>  struct bt_bap_codec {
>         uint8_t  id;
> -       uint16_t vid;
>         uint16_t cid;
> +       uint16_t vid;
>  } __packed;
>
>  struct bt_ltv {
> --
> 2.25.1
>
diff mbox series

Patch

diff --git a/src/shared/bap.c b/src/shared/bap.c
index c3c0d596f..0ae0eba33 100644
--- a/src/shared/bap.c
+++ b/src/shared/bap.c
@@ -416,6 +416,8 @@  static void pac_foreach(void *data, void *user_data)
 
 	p = iov_add(iov, sizeof(*p));
 	p->codec.id = pac->codec.id;
+	p->codec.cid = pac->codec.cid;
+	p->codec.vid = pac->codec.vid;
 
 	if (pac->data) {
 		p->cc_len = pac->data->iov_len;
@@ -2415,6 +2417,9 @@  struct bt_bap_pac *bt_bap_add_vendor_pac(struct gatt_db *db,
 	if (!bdb)
 		return NULL;
 
+	if ((id != 0xff) && ((cid != 0U)  || (vid != 0U)))
+		return NULL;
+
 	codec.id = id;
 	codec.cid = cid;
 	codec.vid = vid;
diff --git a/src/shared/bap.h b/src/shared/bap.h
index 7b9f88c83..923669f32 100644
--- a/src/shared/bap.h
+++ b/src/shared/bap.h
@@ -39,8 +39,8 @@  struct bt_bap_stream;
 
 struct bt_bap_codec {
 	uint8_t  id;
-	uint16_t vid;
 	uint16_t cid;
+	uint16_t vid;
 } __packed;
 
 struct bt_ltv {