shared/bap: Fix load of misaligned address error
authorIulia Tanasescu <iulia.tanasescu@nxp.com>
Wed, 2 Oct 2024 13:35:06 +0000 (16:35 +0300)
committerWootak Jung <wootak.jung@samsung.com>
Thu, 20 Feb 2025 07:43:23 +0000 (16:43 +0900)
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
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
src/shared/bap.c

index 72f0f8a039dc9fa1fd55270a6440b97c41a86d0a..00c3b9ff6a1b5c3dec0c01bb951fcae0ec488777 100644 (file)
@@ -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;