diff mbox series

[BlueZ,1/1] shared/bap: Fix load of misaligned address error

Message ID 20241002133506.16834-2-iulia.tanasescu@nxp.com
State New
Headers show
Series shared/bap: Fix load of misaligned address error | expand

Commit Message

Iulia Tanasescu Oct. 2, 2024, 1:35 p.m. UTC
This fixes the "load of misaligned address" error that appears when
parsing PAC caps:

src/shared/bap.c:6497:7: runtime error: load of misaligned address
0x502000063639 for type 'uint16_t', which requires 2 byte alignment

0x502000063639: note: pointer points here
 02 03 05  04 1a 00 f0 00 02 03 01  02 11 00 00 08 00 00 00  a3 00 00
              ^                        00 00 00 00 00  01 00 00 00 01

src/shared/bap.c:6498:7: runtime error: load of misaligned address
0x502000063639 for type 'uint16_t', which requires 2 byte alignment

0x502000063639: note: pointer points here
 02 03 05  04 1a 00 f0 00 02 03 01  02 11 00 00 08 00 00 00  a3 00 00
              ^                        00 00 00 00 00  01 00 00 00 01
---
 src/shared/bap.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/src/shared/bap.c b/src/shared/bap.c
index 72f0f8a03..00c3b9ff6 100644
--- a/src/shared/bap.c
+++ b/src/shared/bap.c
@@ -6484,8 +6484,8 @@  static void check_pac_caps_ltv(size_t i, uint8_t l, uint8_t t, uint8_t *v,
 
 	switch (t) {
 	case BAP_FREQ_LTV_TYPE:
-		mask = *((uint16_t *)v);
-		mask = le16_to_cpu(mask);
+		mask = get_le16(v);
+
 		if (mask & (1 << (bis_v[0] - 1)))
 			compare_data->data32 |= 1<<t;
 		break;
@@ -6494,12 +6494,10 @@  static void check_pac_caps_ltv(size_t i, uint8_t l, uint8_t t, uint8_t *v,
 			compare_data->data32 |= 1<<t;
 		break;
 	case BAP_FRAME_LEN_LTV_TYPE:
-		min = *((uint16_t *)v);
-		max = *((uint16_t *)(&v[2]));
-		frame_len = *((uint16_t *)bis_v);
-		min = le16_to_cpu(min);
-		max = le16_to_cpu(max);
-		frame_len = le16_to_cpu(frame_len);
+		min = get_le16(v);
+		max = get_le16(v + 2);
+		frame_len = get_le16(bis_v);
+
 		if ((frame_len >= min) &&
 				(frame_len <= max))
 			compare_data->data32 |= 1<<t;