2023-01-13 05:11:08

by Abhay Maheta

[permalink] [raw]
Subject: [PATCH BlueZ v3] shared/bap: Fixing Company ID, Vendor ID and Metadata handling

This fixes Company ID, Vendor Codec ID and metadata storing
PAC record.
---
src/shared/bap.c | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/src/shared/bap.c b/src/shared/bap.c
index 0cafb75e6..463cdb7a6 100644
--- a/src/shared/bap.c
+++ b/src/shared/bap.c
@@ -344,8 +344,10 @@ static void pac_foreach(void *data, void *user_data)

p = util_iov_push(iov, sizeof(*p));
p->codec.id = pac->codec.id;
- p->codec.cid = pac->codec.cid;
- p->codec.vid = pac->codec.vid;
+ if (p->codec.id == 0xff) {
+ p->codec.cid = cpu_to_le16(pac->codec.cid);
+ p->codec.vid = cpu_to_le16(pac->codec.vid);
+ }

if (pac->data) {
p->cc_len = pac->data->iov_len;
@@ -2773,7 +2775,7 @@ static void bap_parse_pacs(struct bt_bap *bap, uint8_t type,
struct bt_pac *p;
struct bt_ltv *cc;
struct bt_pac_metadata *meta;
- struct iovec data, metadata;
+ struct iovec data, *metadata = NULL;

p = util_iov_pull_mem(&iov, sizeof(*p));
if (!p) {
@@ -2802,8 +2804,11 @@ static void bap_parse_pacs(struct bt_bap *bap, uint8_t type,
data.iov_len = p->cc_len;
data.iov_base = cc;

- metadata.iov_len = meta->len;
- metadata.iov_base = meta->data;
+ if (meta->len) {
+ metadata = new0(struct iovec, 1);
+ metadata->iov_len = meta->len;
+ metadata->iov_base = meta->data;
+ }

util_iov_pull_mem(&iov, meta->len);

@@ -2813,12 +2818,14 @@ static void bap_parse_pacs(struct bt_bap *bap, uint8_t type,
/* Check if there is already a PAC record for the codec */
pac = bap_pac_find(bap->rdb, type, &p->codec);
if (pac) {
- bap_pac_merge(pac, &data, &metadata);
+ bap_pac_merge(pac, &data, metadata);
+ free(metadata);
continue;
}

pac = bap_pac_new(bap->rdb, NULL, type, &p->codec, NULL, &data,
- &metadata);
+ metadata);
+ free(metadata);
if (!pac)
continue;

--
2.25.1


2023-01-13 06:18:27

by bluez.test.bot

[permalink] [raw]
Subject: RE: [BlueZ,v3] shared/bap: Fixing Company ID, Vendor ID and Metadata handling

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=711581

---Test result---

Test Summary:
CheckPatch PASS 0.40 seconds
GitLint PASS 0.27 seconds
BuildEll PASS 26.41 seconds
BluezMake PASS 757.26 seconds
MakeCheck PASS 11.02 seconds
MakeDistcheck PASS 147.39 seconds
CheckValgrind PASS 240.33 seconds
CheckSmatch PASS 321.90 seconds
bluezmakeextell PASS 96.27 seconds
IncrementalBuild PASS 623.21 seconds
ScanBuild WARNING 980.31 seconds

Details
##############################
Test: ScanBuild - WARNING
Desc: Run Scan Build
Output:
src/shared/bap.c:2268:26: warning: Access to field 'iov_len' results in a dereference of a null pointer (loaded from variable 'cont')
return iov_append(data, cont->iov_len, cont->iov_base);
^~~~~~~~~~~~~
1 warning generated.



---
Regards,
Linux Bluetooth

2023-01-13 20:44:01

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [PATCH BlueZ v3] shared/bap: Fixing Company ID, Vendor ID and Metadata handling

Hi Abhay,

On Thu, Jan 12, 2023 at 9:11 PM Abhay Maheta
<[email protected]> wrote:
>
> This fixes Company ID, Vendor Codec ID and metadata storing
> PAC record.
> ---
> src/shared/bap.c | 21 ++++++++++++++-------
> 1 file changed, 14 insertions(+), 7 deletions(-)
>
> diff --git a/src/shared/bap.c b/src/shared/bap.c
> index 0cafb75e6..463cdb7a6 100644
> --- a/src/shared/bap.c
> +++ b/src/shared/bap.c
> @@ -344,8 +344,10 @@ static void pac_foreach(void *data, void *user_data)
>
> p = util_iov_push(iov, sizeof(*p));
> p->codec.id = pac->codec.id;
> - p->codec.cid = pac->codec.cid;
> - p->codec.vid = pac->codec.vid;
> + if (p->codec.id == 0xff) {
> + p->codec.cid = cpu_to_le16(pac->codec.cid);
> + p->codec.vid = cpu_to_le16(pac->codec.vid);
> + }
>
> if (pac->data) {
> p->cc_len = pac->data->iov_len;
> @@ -2773,7 +2775,7 @@ static void bap_parse_pacs(struct bt_bap *bap, uint8_t type,
> struct bt_pac *p;
> struct bt_ltv *cc;
> struct bt_pac_metadata *meta;
> - struct iovec data, metadata;
> + struct iovec data, *metadata = NULL;
>
> p = util_iov_pull_mem(&iov, sizeof(*p));
> if (!p) {
> @@ -2802,8 +2804,11 @@ static void bap_parse_pacs(struct bt_bap *bap, uint8_t type,
> data.iov_len = p->cc_len;
> data.iov_base = cc;
>
> - metadata.iov_len = meta->len;
> - metadata.iov_base = meta->data;
> + if (meta->len) {
> + metadata = new0(struct iovec, 1);
> + metadata->iov_len = meta->len;
> + metadata->iov_base = meta->data;
> + }

I'm trying to understand why you have done an extra copy of the
metadata if later it will be copied by the likes of util_iov_dup
inside bap_pac_new?

>
> util_iov_pull_mem(&iov, meta->len);
>
> @@ -2813,12 +2818,14 @@ static void bap_parse_pacs(struct bt_bap *bap, uint8_t type,
> /* Check if there is already a PAC record for the codec */
> pac = bap_pac_find(bap->rdb, type, &p->codec);
> if (pac) {
> - bap_pac_merge(pac, &data, &metadata);
> + bap_pac_merge(pac, &data, metadata);
> + free(metadata);
> continue;
> }
>
> pac = bap_pac_new(bap->rdb, NULL, type, &p->codec, NULL, &data,
> - &metadata);
> + metadata);
> + free(metadata);
> if (!pac)
> continue;
>
> --
> 2.25.1
>


--
Luiz Augusto von Dentz

2023-01-13 23:07:57

by patchwork-bot+bluetooth

[permalink] [raw]
Subject: Re: [PATCH BlueZ v3] shared/bap: Fixing Company ID, Vendor ID and Metadata handling

Hello:

This patch was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <[email protected]>:

On Fri, 13 Jan 2023 10:36:05 +0530 you wrote:
> This fixes Company ID, Vendor Codec ID and metadata storing
> PAC record.
> ---
> src/shared/bap.c | 21 ++++++++++++++-------
> 1 file changed, 14 insertions(+), 7 deletions(-)

Here is the summary with links:
- [BlueZ,v3] shared/bap: Fixing Company ID, Vendor ID and Metadata handling
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=fd893fdd814e

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html