Skip to content

Commit 129fa60

Browse files
neosys007Vudentz
authored andcommitted
Bluetooth: btusb: clamp SCO altsetting table indices
btusb_work() maps the number of active SCO links to USB alternate settings through a three-entry lookup table when CVSD traffic uses transparent voice settings. The lookup currently indexes alts[] with data->sco_num - 1 without first constraining sco_num to the number of available table entries. While the table only defines alternate settings for up to three SCO links, data->sco_num comes from hci_conn_num() and is used directly. Cap the lookup to the last table entry before indexing it so the driver keeps selecting the highest supported alternate setting without reading past alts[]. Fixes: baac627 ("Bluetooth: btusb: handle mSBC audio over USB Endpoints") Signed-off-by: Pengpeng Hou <[email protected]> Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent 25f420a commit 129fa60

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

drivers/bluetooth/btusb.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2376,8 +2376,11 @@ static void btusb_work(struct work_struct *work)
23762376
if (data->air_mode == HCI_NOTIFY_ENABLE_SCO_CVSD) {
23772377
if (hdev->voice_setting & 0x0020) {
23782378
static const int alts[3] = { 2, 4, 5 };
2379+
unsigned int sco_idx;
23792380

2380-
new_alts = alts[data->sco_num - 1];
2381+
sco_idx = min_t(unsigned int, data->sco_num - 1,
2382+
ARRAY_SIZE(alts) - 1);
2383+
new_alts = alts[sco_idx];
23812384
} else {
23822385
new_alts = data->sco_num;
23832386
}

0 commit comments

Comments
 (0)