Skip to content

Commit 5ebe119

Browse files
Thalleymmahadevan108
authored andcommitted
tests: Bluetooth: Tester: Fix use of uninitialized cig_id for CAP
The CAP tests used u_group->cig->index but the u_group->cig may have been deleted when the stream is released, which meant that u_group->cig == NULL when e.g. unicast_stop_complete_cb was called and that could cause failing tests as the index would just be a uninitialized value. Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
1 parent 74a5599 commit 5ebe119

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

tests/bluetooth/tester/src/audio/btp_bap_unicast.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,6 +1140,7 @@ int btp_bap_unicast_group_create(uint8_t cig_id,
11401140
}
11411141

11421142
cigs[cig_id].in_use = true;
1143+
cigs[cig_id].cig_id = cig_id;
11431144
*out_unicast_group = &cigs[cig_id];
11441145

11451146
return 0;

tests/bluetooth/tester/src/audio/btp_bap_unicast.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22

33
/*
44
* Copyright (c) 2023 Codecoup
5+
* Copyright (c) 2024 Nordic Semiconductor ASA
56
*
67
* SPDX-License-Identifier: Apache-2.0
78
*/
89

10+
#include <stdint.h>
11+
912
#include <zephyr/bluetooth/audio/cap.h>
1013

1114
#define BTP_BAP_UNICAST_MAX_SNK_STREAMS_COUNT MIN(CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SNK_COUNT, \
@@ -20,6 +23,7 @@
2023
struct btp_bap_unicast_group {
2124
struct bt_bap_qos_cfg qos[CONFIG_BT_BAP_UNICAST_CLIENT_GROUP_STREAM_COUNT];
2225
struct bt_bap_unicast_group *cig;
26+
uint8_t cig_id;
2327
bool in_use;
2428
};
2529

tests/bluetooth/tester/src/audio/btp_cap.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,13 @@ static void unicast_start_complete_cb(int err, struct bt_conn *conn)
104104

105105
if (err != 0) {
106106
LOG_DBG("Failed to unicast-start, err %d", err);
107-
btp_send_cap_unicast_start_completed_ev(u_group->cig->index,
107+
btp_send_cap_unicast_start_completed_ev(u_group->cig_id,
108108
BTP_CAP_UNICAST_START_STATUS_FAILED);
109109

110110
return;
111111
}
112112

113-
btp_send_cap_unicast_start_completed_ev(u_group->cig->index,
113+
btp_send_cap_unicast_start_completed_ev(u_group->cig_id,
114114
BTP_CAP_UNICAST_START_STATUS_SUCCESS);
115115
}
116116

@@ -129,13 +129,13 @@ static void unicast_stop_complete_cb(int err, struct bt_conn *conn)
129129

130130
if (err != 0) {
131131
LOG_DBG("Failed to unicast-stop, err %d", err);
132-
btp_send_cap_unicast_stop_completed_ev(u_group->cig->index,
132+
btp_send_cap_unicast_stop_completed_ev(u_group->cig_id,
133133
BTP_CAP_UNICAST_START_STATUS_FAILED);
134134

135135
return;
136136
}
137137

138-
btp_send_cap_unicast_stop_completed_ev(u_group->cig->index,
138+
btp_send_cap_unicast_stop_completed_ev(u_group->cig_id,
139139
BTP_CAP_UNICAST_START_STATUS_SUCCESS);
140140
}
141141

0 commit comments

Comments
 (0)