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 CEFD227466A; Mon, 13 Apr 2026 16:33:34 +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=1776098014; cv=none; b=DnsB/znEiHv7zGqujhBgVeZr0VNl1KyYKg369BULadpZHq/C6i9szLP5K6f28So2T7p9LRmSnvCvwro5IyiOp7N2N47PZX8YDfJyDv519Osxu04YEomaOEDbVmHBPeLcdTDlfX3n3Lxt6RbHQnnuMDY7ZkUdgxRSx65HcTBEkNM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776098014; c=relaxed/simple; bh=UHtXWqbAep0UFM+I13OdIYllL8Mo7Dd9DKOc29i51GY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZIyW71NOBOek+DAikAf7eCsrg/4uluOKGoKfiwu38yquZn+IrbgB1MPEveHwHT/UuWVLqLDqbMU89PHOLBvygXihuNJUoqKdtDJ4BAUUPlGd4i9zSiiiqWtcyAh8YcyOLZSSYfVzmMich9Pbmchs+zYEuQdd48f2pUqxj9Z6IGM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ssn1DhO+; 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="ssn1DhO+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 64AEEC2BCB3; Mon, 13 Apr 2026 16:33:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1776098014; bh=UHtXWqbAep0UFM+I13OdIYllL8Mo7Dd9DKOc29i51GY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ssn1DhO+9pIy2rfrNeAuGwOH0HAW+5zNfcSuBaHl3fV7hvUtv5n9+E63gixXq4Chj gTi7boQPbSSoZgKoLwsJo3ER848UrUADTIcg6SHs9EM4MUmtieQbDaDsnu/S7I9TYz Jt4Vmq4eozeacPi3WeKUXp31+5oH4ih/QSXQsJcQ= 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 5.15 333/570] Bluetooth: btusb: clamp SCO altsetting table indices Date: Mon, 13 Apr 2026 17:57:44 +0200 Message-ID: <20260413155842.969063943@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260413155830.386096114@linuxfoundation.org> References: <20260413155830.386096114@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-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 a79fd106fad7a..12bcc07e2e502 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -1845,8 +1845,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