Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2395877lqp; Sun, 24 Mar 2024 17:38:32 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV8OlKOfQ02iN3kx4Hpy/DnU8R0m4GF16b+IjgOyDHgqcLkAEM7o36PJHXeFmpkd5zBSUjm3pyi2TfR2HU5z82mytXRoHWyJKgyVlfUWw== X-Google-Smtp-Source: AGHT+IHyyhHdPCNYwKzWKj6DN3tkuNKmrjoKaKkiSf0kodw4impu/+2XiRHhlR2KEJWsK0Xza30b X-Received: by 2002:a17:906:7194:b0:a44:e34a:792f with SMTP id h20-20020a170906719400b00a44e34a792fmr3615126ejk.15.1711327111940; Sun, 24 Mar 2024 17:38:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711327111; cv=pass; d=google.com; s=arc-20160816; b=OjTbFtmT5H4CjPpnI4hPKqXdL+ddIOMW+1wNT4zuYQCqbPK+UShXNsDgBiKGbK3GPA L1TiEcwPfbpzecSA+g0pwQOcR6oAyHpr8c5QvKfGyF/yfwZDneRIMgeiF+IhlMn+E1Z+ DoFKirQPvSa05i2OUdZ05V5Eu7gm9pj+2Z3XldepgXHQPXBSNfCp1grvIM7nEzVg74UJ ZtXqi0x9p2fPTIyij2v39YxZKmN8TIjQ/UzYkae0yCcKr9PLYBzVVaNlzmEALzOqL1Ry uD37ZuPyyRae8vOhfiret1HUSwtXI/H/A58zaJQTv7Y4ia9xo6hnRvbuxpj38012y9Vw LK2g== 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=BZunYc+M/qS9xAI1uNanxiTe44ws0a1d0lDF4wok2g8FTekoJwSToGBL9ZQaKyUAbR f/XZOhXmsmK38B3DD0i/08swLCr0XZ81IdsT/BfuBuACHdUVcps1QgpzfpoPb/0wEQut 6RwmF4NJF259dStADGODLw4pE63+QnFHKERC9kMHZ7++yof//bwXT8OftYqlac0QWkEQ 6ir45ohY+6kT01xnzin+w8gMsuCEBB10DzGJYykNloxFUFHy1OjQnfUDiY+N1d34UEy2 0CdC3t0Qwi1GUVwVPiOmttIF4CzCyyYFr4ciq5reaXDC81TNuW44Kc4mUyqcK54tEJet YLIw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=D+w8WdTD; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113443-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113443-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id i3-20020a1709064fc300b00a4693947fcdsi2082582ejw.948.2024.03.24.17.38.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 17:38:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-113443-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=D+w8WdTD; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113443-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113443-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 am.mirrors.kernel.org (Postfix) with ESMTPS id D420B1F24472 for ; Mon, 25 Mar 2024 00:38:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0BF8D1AC782; Sun, 24 Mar 2024 22:44:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="D+w8WdTD" 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 0AC751ACFE8; Sun, 24 Mar 2024 22:44:05 +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=1711320245; cv=none; b=N/QBNVjRVoZ1MswF8m1TBM02txOyzVlDna+pdKs6XC6j2YEMviBhRNugDNrdTzUgiuVs/bdaJhVZt+zCfEbf4yevwEEEtFhLXnTrDRlj28uPyHiKILqpyjH74cwcegpai1odBgIC7Rd5JH7N1fGdw55kEbU2LmEJDwj5zMB7+Mg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320245; c=relaxed/simple; bh=c+A4NeIGq37Vm8i5Cry9H8iEiSFWR9RE6zV+f7W98mQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RohPu/NR+o4hBYgxfDb8KElY2Xg2CsjbzmeVgeLfjt/jZYqqhG0xuesvhPvupAx4XqpJ1JKkybvk7sYKMoWy3hU5pLoVbCBMVFp8q6wizKNxOwnqVn6SyCRZHkS+MALPd88spIbDgQRA+iL58nLBimv0kyCPAwGB62HWQGMlHdM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=D+w8WdTD; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3FA8BC43394; Sun, 24 Mar 2024 22:44:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711320244; bh=c+A4NeIGq37Vm8i5Cry9H8iEiSFWR9RE6zV+f7W98mQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D+w8WdTDP+BcSslNfdhW8P4opNUwNO8/KWQnBB061wPiwqxXlFNJ13RPoWHR+TUKo UXXGZVIMYk3cXuAMCkzQX34JElFChPft3n0PgVSZkutP28DO863lgIosl1aUj+rH1f xuPwTp+mj4dA8q5NAJPSanaBbCKgdseINK/KZZ+BQsLemGY3Qf5IqEZgoCSrT0YP7v EH/FoKRgCqJRjAoJm5nbtvMRAoCY4YP5v6bR+m3faKA1Rb6FtsWOkUBD37571QwhkI fQAK2cn0dqqWBawggG7c+pCaI/6xMMCvZrgjPQT+QeOg8GbtxdBWmDr7v1ZvWqolje /8iQ8wfs2tMdQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Johan Carlsson , Takashi Iwai , Sasha Levin Subject: [PATCH 6.8 552/715] ALSA: usb-audio: Stop parsing channels bits when all channels are found. Date: Sun, 24 Mar 2024 18:32:11 -0400 Message-ID: <20240324223455.1342824-553-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324223455.1342824-1-sashal@kernel.org> References: <20240324223455.1342824-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