Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2543566lqp; Mon, 25 Mar 2024 01:57:04 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXdDbsam0RmqYS744+mJxhMgEF5grul8sIW73Sv6PUCcCqErmyZK7n2WejiHw4057XxIHAN9dFLzGOWWRKw2dkDNmADDcS92avQ4El47A== X-Google-Smtp-Source: AGHT+IGag3DTqfGEoniijsmxHrbzVdhuIZ5khmO0Bgeq7VFxkhMHyWiNUm720YLn0nnZY4sFODmH X-Received: by 2002:a05:6a00:1897:b0:6e5:43b5:953b with SMTP id x23-20020a056a00189700b006e543b5953bmr6293504pfh.14.1711357024611; Mon, 25 Mar 2024 01:57:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711357024; cv=pass; d=google.com; s=arc-20160816; b=QeD/VlxK8UJD/WHnu97y6c2EfbH2dfD+6d2OYLMEymDyTw5JFgBVKLy9UUwDTe6exZ Fk3rU3clC0Zo8f/gsKFgzc7ib9x+F2YtF6ZlUnIgyjiMU6MQvKbp2igy5VOIHeNejl6v u0RRh7rzA7ro0KREb8RPYrHF1v364gs5zTMsGu37pMyrDqF9fEGP9lCOKXKXu/iAc6tg CeoqQBl9+2TSH11d9/xVhgIVYTs2znrOvPYqVwPL2jZt5YoEPTT0Sqwqw265Qi0GBx6F ubdyAsi+nat4AadqYGLGafog4p/1js5FyXZZWFqHujyQ85hptbxSIZ9TmnC2Adryi+dK W9mA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=4yie9pi/G+7ksfqFyWOCXiMh+5UkaBqXd81Ew2bCfFI=; fh=8qyEoaoRvFvJ007VK+G5I8+y8Kooh3el/3PSY9VQDNw=; b=wyRlWzLzk+plMKipd4VJiemq0lhkJ/yBxMaPkcK4MCVe0bR0Hc7a/MLObcbrXMqgBU sQzzUQ5P5RigjTyvsdk2gkaAP9VYh5M4EKdICjcF+cTrB09WH/5pGaiPg4/UqYARumME jRVTa7yMsv7DlXzyYNslmmk7mX4kMT4dSz1TXWMvrivYorD/vG5dQ8GQXL/CO52m7KZ0 CjnESX6utDs6mktyOrUOPJ3CwNoPrlv+QEOwDHPtdBiQE/aQLQMnNmYNmIxWhd8XdKPq yOh8plXrmxFALaG2fXVsBr2xFKsGOKcMxeslz7p//NzqGWwnCFkl3nJ65LXGdOixWfu0 b4nQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=c7nQzA+H; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-115975-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-115975-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id g17-20020aa79dd1000000b006e69b40d4adsi4711262pfq.100.2024.03.25.01.57.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 01:57:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-115975-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=c7nQzA+H; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-115975-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-115975-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 7181729B59A for ; Mon, 25 Mar 2024 08:55:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2803439590F; Mon, 25 Mar 2024 03:04:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="c7nQzA+H" 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 96BFD15E20D; Sun, 24 Mar 2024 23:17:45 +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=1711322266; cv=none; b=BMOnDfPof1VwpkCfwWXXvUzDmnxJx+dw6tR4xYTMbCiH4NJ5cxxZ7sh6o6M6pVoHyoQ5/lgVP8v7CZDgvGYUo1NcO+6q8MvcbBIl5rjVi0N59wsmPfOEY9ltocKuDuZMjxzT5ULJb2STZjU23xrliSwoq0EQDA6rSsrIjrdlJJ8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711322266; c=relaxed/simple; bh=c+A4NeIGq37Vm8i5Cry9H8iEiSFWR9RE6zV+f7W98mQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BUbYjCn2y5p3RiWHDR9gDjvzYtBUP+9N7RmcR03wcyisnts7Uh+oC7+N+Fd9XP8d/0Up0pws+sJcxST+tydZi+0dab+S7IsJb0YTokYeHkq0YMDtt7zbqtqctpQG8ozwGb/meuajia2fspfjrsdMAwGLWNy06RH7lP066dKFLyU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=c7nQzA+H; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D2DE7C43390; Sun, 24 Mar 2024 23:17:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711322265; bh=c+A4NeIGq37Vm8i5Cry9H8iEiSFWR9RE6zV+f7W98mQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c7nQzA+HS9yywZSYv/16U1J8UbTbuwbrvqmXenrDsYnWzlLUO0OelfIJRuyL0LWuD 7Ipk2ycuVoP6EK6ptrhIRFpZCPqI6eQYsgL8Dg6TOgmOUj7YL/q4TFEA3SHa0u7ygq ZcErsUvLJC3b5Ss4VnzhXiVg9ZKYKOmfcEMSN3LMmzWb7EfUNm6XlTZ7RFgmoSFwPO blRwjNpp6QLaDV9VZSjS9BwKGRFY9yK4ueNenqc0X4joVRz5waloMEIkZNIzVFSmvP 4BYg/U31NETy4uRnFKYl9qVfO7nZye4k9yo1v5N4NKTbKP34juCR9YxPppvempjBgR Vy5JN6SJIxsdw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Johan Carlsson , Takashi Iwai , Sasha Levin Subject: [PATCH 6.1 348/451] ALSA: usb-audio: Stop parsing channels bits when all channels are found. Date: Sun, 24 Mar 2024 19:10:24 -0400 Message-ID: <20240324231207.1351418-349-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324231207.1351418-1-sashal@kernel.org> References: <20240324231207.1351418-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Johan Carlsson [ Upstream commit a39d51ff1f52cd0b6fe7d379ac93bd8b4237d1b7 ] If a usb audio device sets more bits than the amount of channels it could write outside of the map array. Signed-off-by: Johan Carlsson Fixes: 04324ccc75f9 ("ALSA: usb-audio: add channel map support") Message-ID: <20240313081509.9801-1-johan.carlsson@teenage.engineering> Signed-off-by: Takashi Iwai Signed-off-by: Sasha Levin --- sound/usb/stream.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sound/usb/stream.c b/sound/usb/stream.c index 3d4add94e367d..d5409f3879455 100644 --- a/sound/usb/stream.c +++ b/sound/usb/stream.c @@ -300,9 +300,12 @@ static struct snd_pcm_chmap_elem *convert_chmap(int channels, unsigned int bits, c = 0; if (bits) { - for (; bits && *maps; maps++, bits >>= 1) + for (; bits && *maps; maps++, bits >>= 1) { if (bits & 1) chmap->map[c++] = *maps; + if (c == chmap->channels) + break; + } } else { /* If we're missing wChannelConfig, then guess something to make sure the channel map is not skipped entirely */ -- 2.43.0