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 048C515C83 for ; Mon, 5 Dec 2022 19:27:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 76A18C433D6; Mon, 5 Dec 2022 19:27:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1670268434; bh=uW5uTRZTuxMZHR3U7WFYwoQg8VuSbGwHOiiMqYZKELI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DvBNW/T4RNEGTvewERkudLJd5HCBMD3UzzjqUmgE2xTNk/V6mAfYhrb7cpvrVw65+ BjIAjd0CfKHL6kMQ/evydU/6iH45RUVenbFUJHSoYw65xn44zzOVctW9DsI+nBxQeH mwwDSXUNBiYfEmPeIsHq6gIgkzIze1uG6wUkEuAs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Mark Brown , Sasha Levin Subject: [PATCH 6.0 101/124] ASoC: ops: Fix bounds check for _sx controls Date: Mon, 5 Dec 2022 20:10:07 +0100 Message-Id: <20221205190811.290021521@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221205190808.422385173@linuxfoundation.org> References: <20221205190808.422385173@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Mark Brown [ Upstream commit 698813ba8c580efb356ace8dbf55f61dac6063a8 ] For _sx controls the semantics of the max field is not the usual one, max is the number of steps rather than the maximum value. This means that our check in snd_soc_put_volsw_sx() needs to just check against the maximum value. Fixes: 4f1e50d6a9cf9c1b ("ASoC: ops: Reject out of bounds values in snd_soc_put_volsw_sx()") Signed-off-by: Mark Brown Link: https://lore.kernel.org/r/20220511134137.169575-1-broonie@kernel.org 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 bd88de056358..47691119306f 100644 --- a/sound/soc/soc-ops.c +++ b/sound/soc/soc-ops.c @@ -452,7 +452,7 @@ int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol, val = ucontrol->value.integer.value[0]; if (mc->platform_max && val > mc->platform_max) return -EINVAL; - if (val > max - min) + if (val > max) return -EINVAL; val_mask = mask << shift; val = (val + min) & mask; -- 2.35.1