From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 536243DB62F; Tue, 31 Mar 2026 16:26:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774974392; cv=none; b=RU+RWe8nHU2laB7ktm8Pbes9IhkJrCfhfugRs1Qn+8KfSg51nW5RX0LNaCm8zTotIbjXbW+27OHm19CNf66hKLQFv1Y51sQhf+F77T7lgkUaUzq191fF8Q5nWeP5evfdQi0UZ2gM089GZfYQADx+i8b2mO14Bi5apgttzfY35I4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774974392; c=relaxed/simple; bh=yYkISdMK1T+8vfyx4Vfv4Sppyu3xpFQU6qU9NF1pOcI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fuLglFhSHVorSJTN+7ZF1vEPr6SfjfSr/ROSlaTevxzh58uarSyNW5tTw4O9jVAwrbwd299geNkVoMq2+SIY5+kfiuVq1CLUI6i1/Gfpt1ZzcD6jx2P27S2dmRJFT5lJ3Zl3MhjixCvGL2GBzNRnwt9kLzW8HLW78O7V6OF0GU4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=jFqp3c8B; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="jFqp3c8B" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E21DAC19423; Tue, 31 Mar 2026 16:26:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1774974392; bh=yYkISdMK1T+8vfyx4Vfv4Sppyu3xpFQU6qU9NF1pOcI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jFqp3c8BAWLZ9ys2jV5WFQBvG1iGmYAWGVG9RvPZ2XYhRn3NxLhJwhrszUXcd2NB6 PKVYoRgX1mVfwe7HRteJUrLm8GAevAimHoIX8vOO80HMe5gtpBt3vkqgx3JNiXALfP eXnA/qL3pplD8QmFhzyoAjN42JUhmEJwq5cREkT4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Pengpeng Hou , Luiz Augusto von Dentz , Sasha Levin Subject: [PATCH 6.6 067/175] Bluetooth: btusb: clamp SCO altsetting table indices Date: Tue, 31 Mar 2026 18:20:51 +0200 Message-ID: <20260331161732.243090230@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260331161729.779738837@linuxfoundation.org> References: <20260331161729.779738837@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Pengpeng Hou [ Upstream commit 129fa608b6ad08b8ab7178eeb2ec272c993aaccc ] 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: baac6276c0a9 ("Bluetooth: btusb: handle mSBC audio over USB Endpoints") Signed-off-by: Pengpeng Hou Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Sasha Levin --- drivers/bluetooth/btusb.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index 168e46ce59976..c51523d780e65 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -2314,8 +2314,11 @@ static void btusb_work(struct work_struct *work) if (data->air_mode == HCI_NOTIFY_ENABLE_SCO_CVSD) { if (hdev->voice_setting & 0x0020) { static const int alts[3] = { 2, 4, 5 }; + unsigned int sco_idx; - new_alts = alts[data->sco_num - 1]; + sco_idx = min_t(unsigned int, data->sco_num - 1, + ARRAY_SIZE(alts) - 1); + new_alts = alts[sco_idx]; } else { new_alts = data->sco_num; } -- 2.51.0