From patchwork Sat Jun 4 10:52:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 578757 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D9A12C433EF for ; Sat, 4 Jun 2022 10:53:54 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 260CE184D; Sat, 4 Jun 2022 12:53:02 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 260CE184D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1654340032; bh=aQWGVz14tVMgdX2bV3/UpFILqPAYToEPDjNPLV6X1FY=; h=From:To:Subject:Date:Cc:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=WJ3y/HRPMlDzATaSIMnSNe7p3S7Nin0HpXlNpSri+bT8/nySjwIDzFEWs7Ehqeui0 NKBgcGLMTR8WDcFgpq5h9rF1Uq/3wyscgKiSPafGx4beCA0tluuQrAppxpiEleG3ju m6KGtTM4Ha4QWv0CQibkVBWe2IwGNOmjM6ubFOA4= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id A40DBF80169; Sat, 4 Jun 2022 12:53:01 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 17DA3F8016D; Sat, 4 Jun 2022 12:53:00 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 5D05CF80124 for ; Sat, 4 Jun 2022 12:52:57 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 5D05CF80124 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="rHZfbumU" Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4A2A160A50; Sat, 4 Jun 2022 10:52:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C546EC385B8; Sat, 4 Jun 2022 10:52:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654339973; bh=aQWGVz14tVMgdX2bV3/UpFILqPAYToEPDjNPLV6X1FY=; h=From:To:Cc:Subject:Date:From; b=rHZfbumUs6Zb6nrLIuPMV+r/znrwoNuooS+3YziSQ+vENkmN6w5iqEaeESr4u788r alh3l20mkVM2QQro6AAW0A39SdSG1oLMq5r4HzMr8UDv2VhpexNqf2/TEW55vDWxEZ RWfgau0E4mV1KrXm4IvE7a8pp5K5wxmAIHj0Bp0YWgp2yNNXJtqLlM6DlsN9To8BAk hB3URf6f+KJih9Zf6PgwuhfJ2TaJe8xJK4/fHyUAMu4pN9hZSxiNhPqxueUtAltO/C OWPtUoCsWvXxyyUEJqYeKkrC0dsEq2OgxOvnhO4RhHCUUKPCbz/ClBNRKhvnI/N2z+ TO8Xg20HTkCNw== From: Mark Brown To: Liam Girdwood Subject: [PATCH] ASoC: ops: Fix off by one in range control validation Date: Sat, 4 Jun 2022 11:52:46 +0100 Message-Id: <20220604105246.4055214-1-broonie@kernel.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1005; h=from:subject; bh=aQWGVz14tVMgdX2bV3/UpFILqPAYToEPDjNPLV6X1FY=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBimy6LDNp0ebSWX6Wle08hLwX2sDK/ccNv0HllhgXp mCBHdiWJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCYpsuiwAKCRAk1otyXVSH0MDTB/ 9qTMwUCGLhwV8pF6Q4+7bnSJpPAW0t/t0ATTkHFJ3O4MG+nTtko5S0h3L6I/8+5wm4mdVtZ4C9jTh5 s20YTf4ucsaMOALzef4apLTTHy6mDPqZqq04BzT7VKOWwXKAXtTJw6rLt2qqtiMCONUzSnryLiGRQt 31SqVctrl9Nxysmn3bP1qovsm4m5xAXMLWHaBSgpGp8fF7de8wAfe4E/MDd+iQeU5MwkxoUjhnfP0P B/3X498J+J60yc3qrQIKaH53yPuPn45rQwnBDUGFmOzb2dqbr5BkNrCm6EVrOxbUUHxEBpBSIjHWSv gTOrRbXnlaHmEo/L9g16TJNei83WEW X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB Cc: alsa-devel@alsa-project.org, Mark Brown X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" We currently report that range controls accept a range of 0..(max-min) but accept writes in the range 0..(max-min+1). Remove that extra +1. Signed-off-by: Mark Brown --- sound/soc/soc-ops.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/soc-ops.c b/sound/soc/soc-ops.c index 93e72a016b4d..e11109dcaa50 100644 --- a/sound/soc/soc-ops.c +++ b/sound/soc/soc-ops.c @@ -542,7 +542,7 @@ int snd_soc_put_volsw_range(struct snd_kcontrol *kcontrol, return -EINVAL; if (mc->platform_max && tmp > mc->platform_max) return -EINVAL; - if (tmp > mc->max - mc->min + 1) + if (tmp > mc->max - mc->min) return -EINVAL; if (invert) @@ -563,7 +563,7 @@ int snd_soc_put_volsw_range(struct snd_kcontrol *kcontrol, return -EINVAL; if (mc->platform_max && tmp > mc->platform_max) return -EINVAL; - if (tmp > mc->max - mc->min + 1) + if (tmp > mc->max - mc->min) return -EINVAL; if (invert)