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 1FF3B1474AB; Thu, 11 Apr 2024 10:42:28 +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=1712832148; cv=none; b=Kc/G+IIbJSr+AogpMKV8dtrfEnSOUtZy8CtHywB8X2s7s0S6EV6p3JInkBMDhvlcwKcIYMpy7WIXOwhFVi+PFf9yrniel8iDW+H/hB1M5X6xYlpegLDth8VZy5QSnDDaJG7UaRNuyq8BEsWGEovBx9UMnLJn/hP0B5mVXhyr9ZU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712832148; c=relaxed/simple; bh=K+4SZ1TCz88hEPe+oN0MFSxBbEt222aDiCHa5r2u168=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=N3Z6EF53pj1Wvt8QHpgPmt4rcsl3Eduhc3v68y8HK5pB5+NQDMKIlh35JbnoXy4ZzYWkHRU/8ldIkzu49OQiDN57SmjbI/Pvf8IFDvFBpcEBh8WY2d+a6r10aaj2TqS4NcZA5iKdD98mcGBadxS4tAs8OWmWYjBAWCDjn/+D52E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Q0YAhgTo; 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="Q0YAhgTo" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9172BC43390; Thu, 11 Apr 2024 10:42:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1712832148; bh=K+4SZ1TCz88hEPe+oN0MFSxBbEt222aDiCHa5r2u168=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q0YAhgToI4qtMs8aM7LyY2CNnOUFJPfxWH2fQ1QFgjeGMxPXtNMuTIL7LpbNXKXBW eM4juHivPkWGnifgg9Ou9O22fcrW2tnAHrmyTWnFSBpYiowpXjpg3ZFcy2Y4xCUoRS 3ZJvJlp5aJaXtzqEhgWLEsurEVPbozGjT37LOeMQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Stephen Lee , Mark Brown , Sasha Levin Subject: [PATCH 5.10 228/294] ASoC: ops: Fix wraparound for mask in snd_soc_get_volsw Date: Thu, 11 Apr 2024 11:56:31 +0200 Message-ID: <20240411095442.450994206@linuxfoundation.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240411095435.633465671@linuxfoundation.org> References: <20240411095435.633465671@linuxfoundation.org> User-Agent: quilt/0.67 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 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Stephen Lee [ Upstream commit fc563aa900659a850e2ada4af26b9d7a3de6c591 ] In snd_soc_info_volsw(), mask is generated by figuring out the index of the most significant bit set in max and converting the index to a bitmask through bit shift 1. Unintended wraparound occurs when max is an integer value with msb bit set. Since the bit shift value 1 is treated as an integer type, the left shift operation will wraparound and set mask to 0 instead of all 1's. In order to fix this, we type cast 1 as `1ULL` to prevent the wraparound. Fixes: 7077148fb50a ("ASoC: core: Split ops out of soc-core.c") Signed-off-by: Stephen Lee Link: https://msgid.link/r/20240326010131.6211-1-slee08177@gmail.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/soc-ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/soc-ops.c b/sound/soc/soc-ops.c index daecd386d5ec8..a83cd8d8a9633 100644 --- a/sound/soc/soc-ops.c +++ b/sound/soc/soc-ops.c @@ -246,7 +246,7 @@ int snd_soc_get_volsw(struct snd_kcontrol *kcontrol, int max = mc->max; int min = mc->min; int sign_bit = mc->sign_bit; - unsigned int mask = (1 << fls(max)) - 1; + unsigned int mask = (1ULL << fls(max)) - 1; unsigned int invert = mc->invert; int val; int ret; -- 2.43.0