* [PATCH BlueZ v2 0/2] bap: Allocate memory for broadcast code
@ 2024-06-19 9:51 Vlad Pruteanu
2024-06-19 9:51 ` [PATCH BlueZ v2 1/2] shared/util: Add util_iov_new function Vlad Pruteanu
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Vlad Pruteanu @ 2024-06-19 9:51 UTC (permalink / raw)
To: linux-bluetooth
Cc: mihai-octavian.urzica, iulia.tanasescu, andrei.istodorescu,
luiz.dentz, Vlad Pruteanu
Currently the broadcast code is set without memory being allocated
for it resulting in segmentation fault. This implements an util_iov_new
function that allocates the memory before setting the user_data. The issue is
fixed by using this function instead of util_iov_append.
Vlad Pruteanu (2):
shared/util: Add util_iov_new function
bap: Use util_iov_new when setting bcode
profiles/audio/bap.c | 5 ++---
src/shared/util.c | 10 ++++++++++
src/shared/util.h | 1 +
3 files changed, 13 insertions(+), 3 deletions(-)
--
2.40.1
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH BlueZ v2 1/2] shared/util: Add util_iov_new function
2024-06-19 9:51 [PATCH BlueZ v2 0/2] bap: Allocate memory for broadcast code Vlad Pruteanu
@ 2024-06-19 9:51 ` Vlad Pruteanu
2024-06-19 12:07 ` bap: Allocate memory for broadcast code bluez.test.bot
2024-06-19 9:51 ` [PATCH BlueZ v2 2/2] bap: Use util_iov_new when setting bcode Vlad Pruteanu
2024-06-19 14:10 ` [PATCH BlueZ v2 0/2] bap: Allocate memory for broadcast code patchwork-bot+bluetooth
2 siblings, 1 reply; 6+ messages in thread
From: Vlad Pruteanu @ 2024-06-19 9:51 UTC (permalink / raw)
To: linux-bluetooth
Cc: mihai-octavian.urzica, iulia.tanasescu, andrei.istodorescu,
luiz.dentz, Vlad Pruteanu
This adds the util_iov_new function that allows the user both allocated
and set an iovec to the desired value, using only one function call.
---
src/shared/util.c | 10 ++++++++++
src/shared/util.h | 1 +
2 files changed, 11 insertions(+)
diff --git a/src/shared/util.c b/src/shared/util.c
index 6a29b5068..30f054a5e 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -542,6 +542,16 @@ void *util_iov_append(struct iovec *iov, const void *data, size_t len)
return util_iov_push_mem(iov, len, data);
}
+struct iovec *util_iov_new(void *data, size_t len)
+{
+ struct iovec *iov;
+
+ iov = new0(struct iovec, 1);
+ util_iov_append(iov, data, len);
+
+ return iov;
+}
+
void *util_iov_pull(struct iovec *iov, size_t len)
{
if (!iov)
diff --git a/src/shared/util.h b/src/shared/util.h
index bd71577d6..f2ca4f29f 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -176,6 +176,7 @@ void *util_iov_push_le16(struct iovec *iov, uint16_t val);
void *util_iov_push_be16(struct iovec *iov, uint16_t val);
void *util_iov_push_u8(struct iovec *iov, uint8_t val);
void *util_iov_append(struct iovec *iov, const void *data, size_t len);
+struct iovec *util_iov_new(void *data, size_t len);
void *util_iov_pull(struct iovec *iov, size_t len);
void *util_iov_pull_mem(struct iovec *iov, size_t len);
void *util_iov_pull_le64(struct iovec *iov, uint64_t *val);
--
2.40.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* RE: bap: Allocate memory for broadcast code
2024-06-19 9:51 ` [PATCH BlueZ v2 1/2] shared/util: Add util_iov_new function Vlad Pruteanu
@ 2024-06-19 12:07 ` bluez.test.bot
0 siblings, 0 replies; 6+ messages in thread
From: bluez.test.bot @ 2024-06-19 12:07 UTC (permalink / raw)
To: linux-bluetooth, vlad.pruteanu
[-- Attachment #1: Type: text/plain, Size: 2178 bytes --]
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=863362
---Test result---
Test Summary:
CheckPatch PASS 0.95 seconds
GitLint PASS 0.67 seconds
BuildEll PASS 24.51 seconds
BluezMake PASS 1675.31 seconds
MakeCheck PASS 13.64 seconds
MakeDistcheck PASS 176.61 seconds
CheckValgrind PASS 250.75 seconds
CheckSmatch PASS 352.42 seconds
bluezmakeextell PASS 119.14 seconds
IncrementalBuild PASS 2986.68 seconds
ScanBuild WARNING 1020.79 seconds
Details
##############################
Test: ScanBuild - WARNING
Desc: Run Scan Build
Output:
In file included from tools/mesh-gatt/crypto.c:32:
./src/shared/util.h:240:9: warning: 1st function call argument is an uninitialized value
return be32_to_cpu(get_unaligned((const uint32_t *) ptr));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./src/shared/util.h:33:26: note: expanded from macro 'be32_to_cpu'
#define be32_to_cpu(val) bswap_32(val)
^~~~~~~~~~~~~
/usr/include/byteswap.h:34:21: note: expanded from macro 'bswap_32'
#define bswap_32(x) __bswap_32 (x)
^~~~~~~~~~~~~~
In file included from tools/mesh-gatt/crypto.c:32:
./src/shared/util.h:250:9: warning: 1st function call argument is an uninitialized value
return be64_to_cpu(get_unaligned((const uint64_t *) ptr));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./src/shared/util.h:34:26: note: expanded from macro 'be64_to_cpu'
#define be64_to_cpu(val) bswap_64(val)
^~~~~~~~~~~~~
/usr/include/byteswap.h:37:21: note: expanded from macro 'bswap_64'
#define bswap_64(x) __bswap_64 (x)
^~~~~~~~~~~~~~
2 warnings generated.
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH BlueZ v2 2/2] bap: Use util_iov_new when setting bcode
2024-06-19 9:51 [PATCH BlueZ v2 0/2] bap: Allocate memory for broadcast code Vlad Pruteanu
2024-06-19 9:51 ` [PATCH BlueZ v2 1/2] shared/util: Add util_iov_new function Vlad Pruteanu
@ 2024-06-19 9:51 ` Vlad Pruteanu
2024-06-19 14:10 ` [PATCH BlueZ v2 0/2] bap: Allocate memory for broadcast code patchwork-bot+bluetooth
2 siblings, 0 replies; 6+ messages in thread
From: Vlad Pruteanu @ 2024-06-19 9:51 UTC (permalink / raw)
To: linux-bluetooth
Cc: mihai-octavian.urzica, iulia.tanasescu, andrei.istodorescu,
luiz.dentz, Vlad Pruteanu
Currently the broadcast code is set without memory being allocated
for it resulting in segmentation fault. This fixes the issue by using
the newly created util_iov_new that allocates the memory before
setting it.
---
profiles/audio/bap.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c
index 53e7b3e34..e82a25382 100644
--- a/profiles/audio/bap.c
+++ b/profiles/audio/bap.c
@@ -1042,9 +1042,8 @@ static void create_stream_for_bis(struct bap_data *bap_data,
setup->qos.bcast.framing = qos->bcast.framing;
setup->qos.bcast.encryption = qos->bcast.encryption;
if (setup->qos.bcast.encryption)
- util_iov_append(setup->qos.bcast.bcode,
- qos->bcast.bcode,
- sizeof(qos->bcast.bcode));
+ setup->qos.bcast.bcode = util_iov_new(qos->bcast.bcode,
+ sizeof(qos->bcast.bcode));
setup->qos.bcast.options = qos->bcast.options;
setup->qos.bcast.skip = qos->bcast.skip;
setup->qos.bcast.sync_timeout = qos->bcast.sync_timeout;
--
2.40.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH BlueZ v2 0/2] bap: Allocate memory for broadcast code
2024-06-19 9:51 [PATCH BlueZ v2 0/2] bap: Allocate memory for broadcast code Vlad Pruteanu
2024-06-19 9:51 ` [PATCH BlueZ v2 1/2] shared/util: Add util_iov_new function Vlad Pruteanu
2024-06-19 9:51 ` [PATCH BlueZ v2 2/2] bap: Use util_iov_new when setting bcode Vlad Pruteanu
@ 2024-06-19 14:10 ` patchwork-bot+bluetooth
2 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+bluetooth @ 2024-06-19 14:10 UTC (permalink / raw)
To: Vlad Pruteanu
Cc: linux-bluetooth, mihai-octavian.urzica, iulia.tanasescu,
andrei.istodorescu, luiz.dentz
Hello:
This series was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:
On Wed, 19 Jun 2024 12:51:17 +0300 you wrote:
> Currently the broadcast code is set without memory being allocated
> for it resulting in segmentation fault. This implements an util_iov_new
> function that allocates the memory before setting the user_data. The issue is
> fixed by using this function instead of util_iov_append.
>
> Vlad Pruteanu (2):
> shared/util: Add util_iov_new function
> bap: Use util_iov_new when setting bcode
>
> [...]
Here is the summary with links:
- [BlueZ,v2,1/2] shared/util: Add util_iov_new function
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=503ecbc655c5
- [BlueZ,v2,2/2] bap: Use util_iov_new when setting bcode
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=5ec05848a9d4
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH BlueZ 1/1] bap: Allocate memory for broadcast code
@ 2024-06-18 8:58 Vlad Pruteanu
2024-06-18 10:44 ` bluez.test.bot
0 siblings, 1 reply; 6+ messages in thread
From: Vlad Pruteanu @ 2024-06-18 8:58 UTC (permalink / raw)
To: linux-bluetooth
Cc: mihai-octavian.urzica, silviu.barbulescu, iulia.tanasescu,
andrei.istodorescu, luiz.dentz, Vlad Pruteanu
This fixes segmentation fault caused by trying to write to
unallocated memory.
---
profiles/audio/bap.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c
index 53e7b3e34..3d249a4e4 100644
--- a/profiles/audio/bap.c
+++ b/profiles/audio/bap.c
@@ -1041,10 +1041,12 @@ static void create_stream_for_bis(struct bap_data *bap_data,
setup->qos.bcast.packing = qos->bcast.packing;
setup->qos.bcast.framing = qos->bcast.framing;
setup->qos.bcast.encryption = qos->bcast.encryption;
- if (setup->qos.bcast.encryption)
+ if (setup->qos.bcast.encryption) {
+ setup->qos.bcast.bcode = new0(struct iovec, 1);
util_iov_append(setup->qos.bcast.bcode,
qos->bcast.bcode,
sizeof(qos->bcast.bcode));
+ }
setup->qos.bcast.options = qos->bcast.options;
setup->qos.bcast.skip = qos->bcast.skip;
setup->qos.bcast.sync_timeout = qos->bcast.sync_timeout;
--
2.40.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-06-19 14:10 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-19 9:51 [PATCH BlueZ v2 0/2] bap: Allocate memory for broadcast code Vlad Pruteanu
2024-06-19 9:51 ` [PATCH BlueZ v2 1/2] shared/util: Add util_iov_new function Vlad Pruteanu
2024-06-19 12:07 ` bap: Allocate memory for broadcast code bluez.test.bot
2024-06-19 9:51 ` [PATCH BlueZ v2 2/2] bap: Use util_iov_new when setting bcode Vlad Pruteanu
2024-06-19 14:10 ` [PATCH BlueZ v2 0/2] bap: Allocate memory for broadcast code patchwork-bot+bluetooth
-- strict thread matches above, loose matches on Subject: below --
2024-06-18 8:58 [PATCH BlueZ 1/1] " Vlad Pruteanu
2024-06-18 10:44 ` bluez.test.bot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.