From patchwork Wed Apr 20 19:34:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 565296 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 4F457C433EF for ; Wed, 20 Apr 2022 19:41:01 +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 2B2DF1B28; Wed, 20 Apr 2022 21:40:09 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 2B2DF1B28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1650483659; bh=tc5FOp37X1nlh+h/hDzp8RiZRIjBdt1lbWGyfRjb/YE=; h=From:To:Subject:Date:Cc:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=PAdl4R4rf6iO6fZC36TePoEXtKtDe6LgzNFzV51vTjaiA9X9l67odWU77HhUKWEx2 paXWVgnsiHE0bM1bZ5AEaAFeWIhWM658VkmoMzVcL934GPsGeiXGkge1lY8DLyt2Hb Q+eKtQq0dcdHml1ZDkk1r0bxK+nA70WOcQbvSYBE= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 94AE6F80246; Wed, 20 Apr 2022 21:39:38 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id F034AF800C1; Wed, 20 Apr 2022 21:39:35 +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 929BBF800C1 for ; Wed, 20 Apr 2022 21:39:32 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 929BBF800C1 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bJZcIGT+" 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 74834616AD; Wed, 20 Apr 2022 19:39:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 027FDC385A0; Wed, 20 Apr 2022 19:39:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1650483568; bh=tc5FOp37X1nlh+h/hDzp8RiZRIjBdt1lbWGyfRjb/YE=; h=From:To:Cc:Subject:Date:From; b=bJZcIGT+I2/2WDaUcLZV14eVCGVwMBp3lcWW073t2TpB46QmX6UpMjDpdmbWRlc58 VPMAMx3Vi1xr3N0JLlmqDXrD5usUgxHHyMWrc8ksSkmu77I3R5fBzA4oImdGYJ6050 xaGOu7UrauWc3jjZT5IINMnxxrb7ktAQOSBRPBmpnqh2lp7AvaWD3YvyOJTdg35GG4 BSO2tARIFtI0aQhQ0OilBoB27ghCbKxaX1zcGk/H3Zib+XWr4IphBq01tY/dTZMZQX XPb1B9YciFKJPrKpJgBH19Y46UYrP73gEV9fHBMEmQbdivvecRS6j26BQPQaQGjXhe odz/SzkQHQCxQ== From: Mark Brown To: Mark Brown , Liam Girdwood Subject: [PATCH 1/2] ASoC: max98090: Reject invalid values in custom control put() Date: Wed, 20 Apr 2022 20:34:53 +0100 Message-Id: <20220420193454.2647908-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=933; h=from:subject; bh=tc5FOp37X1nlh+h/hDzp8RiZRIjBdt1lbWGyfRjb/YE=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBiYGA9iH8lWExS5j3bxF5Io32jetcZ/B00KdIrKB8j r9Uly0+JATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCYmBgPQAKCRAk1otyXVSH0BwjB/ 9uHzNQAkofRJkm4IA3zSKFb3o1wfHqCCxz1X+bzw3TwLmTIYjFruin+Eb7UnVeoYHS0BYE6K2zlB4i DxWADpO2HZoByIPVg6jYStlV5zgZ1kvV3FezKvdDWg8At/Aq3X0A/QbcKVK4eIgpioc6fTR4Cb1eC4 0jcP+MLF4Umax5UrJfMHjbmhUn/FA+dKQWqx4dg7i5A/bWfI2wYkmowrVoMf/+B5VbrAc/RXRDJn5m kAM1KxLPgxYApfeHai942i6EbxrxA+Rh6TPpqZzp54rAXIopi7whgNPh7+fRxKKGHG8lpPXaMhQqhM tpaVON93wwvUY6kDmM5qjxYzP3KqLr X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB Cc: alsa-devel@alsa-project.org 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" The max98090 driver has a custom put function for some controls which can only be updated in certain circumstances which makes no effort to validate that input is suitable for the control, allowing out of spec values to be written to the hardware and presented to userspace. Fix this by returning an error when invalid values are written. Signed-off-by: Mark Brown --- sound/soc/codecs/max98090.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c index b45ec35cd63c..6d9261346842 100644 --- a/sound/soc/codecs/max98090.c +++ b/sound/soc/codecs/max98090.c @@ -413,6 +413,9 @@ static int max98090_put_enab_tlv(struct snd_kcontrol *kcontrol, val = (val >> mc->shift) & mask; + if (sel < 0 || sel > mc->max) + return -EINVAL; + *select = sel; /* Setting a volume is only valid if it is already On */ From patchwork Wed Apr 20 19:34:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 564038 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 E27C6C433F5 for ; Wed, 20 Apr 2022 19:40:30 +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 264D71B15; Wed, 20 Apr 2022 21:39:38 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 264D71B15 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1650483628; bh=sqNgD2MXHoQ8IBpAkTanik6at2YkEYuRV3llPRaXE2Y=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=FHYN9M0q3Q/fjd7F4KlVb4MDJHCzYpENfJngRlYHDMEs+Cm4DuIjV75JcORwXVqb0 6oC01DTTmTJSSdGyL8SL4zKX2MmYK6FkjthTjB4+5Ea5J/0AkT+sXclRG0iHgANLqn byr3E3FIcV4M6cn2IWHxC/8Sj5toY5QUp7ZNvzr0= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 83BEDF80116; Wed, 20 Apr 2022 21:39:37 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id D1BC3F80217; Wed, 20 Apr 2022 21:39:35 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 94F87F80116 for ; Wed, 20 Apr 2022 21:39:32 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 94F87F80116 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="l9WZUnoL" 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 C2C2B6126E; Wed, 20 Apr 2022 19:39:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 54855C385A1; Wed, 20 Apr 2022 19:39:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1650483570; bh=sqNgD2MXHoQ8IBpAkTanik6at2YkEYuRV3llPRaXE2Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l9WZUnoLha85T8hpJJCWcMbt42ELnorAvSiBHdcxqEI4SAL6byMI6Jq2zUOEtvpRP XYw9BLdykByjP3EFTC4bN+BSL9sMKfUybGkm/uXp1wBzfflT0PnpnXa/5hYhRYOcAh ujXRNAqgPoiwQNSIRNIOHZ2ZxnRq/M3Xts1A+OGPT2bbMOFJ4E+kbtWhVx7vdReZv0 l6DvEvt1WsdbytMQIkZS82RhsY6Y12NPZZCWg6HhvBH29EkDjHB1bXDOPmNw5J7LEr oi8roa40I4Tlt8p/vSQPqRcr2TFjg0m/aBRVBH0sVmhBeerQ+XH4Xg1O2RBh2+eMco s8yB78y6sNK1g== From: Mark Brown To: Mark Brown , Liam Girdwood Subject: [PATCH 2/2] ASoC: max98090: Generate notifications on changes for custom control Date: Wed, 20 Apr 2022 20:34:54 +0100 Message-Id: <20220420193454.2647908-2-broonie@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220420193454.2647908-1-broonie@kernel.org> References: <20220420193454.2647908-1-broonie@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=748; h=from:subject; bh=sqNgD2MXHoQ8IBpAkTanik6at2YkEYuRV3llPRaXE2Y=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBiYGA+3fRaSeyfAF+zeMr1rkz2tnnBED9m5uZxlswJ Jwrg/2iJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCYmBgPgAKCRAk1otyXVSH0CJ0B/ 98VsCP4EEh45ozL0eI2S9BOOtSVF6R0eAnzAQn36cee+aMxXI72vowTFJMO3FFsv0PGU9GV6Qsg7zr uvk7Npv51beDVa2iVsUn3MfizKEBIkCpJt8OVz6sNANdWMkJ8uLtVJPKMo00wZPAlYWVjtIG5if33s u0oAaY4gNqBNWSieNCemjS8ipQHqYhZC83bt7cH9ESx5NVHN/SQXiRi9tMn+x4PGfF6zgtpnQ4laph ImFfStShavb5th6mHxftQAgOhIf2S19tOWFzAyFZbbTICqs8lCr7/wUjD0NvJRlLbLWf+lE7bTt/VZ HYjPtScsWpFH4ErnsLlHUWkz1VawIw X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB Cc: alsa-devel@alsa-project.org 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" The max98090 driver has some custom controls which share a put() function which returns 0 unconditionally, meaning that events are not generated when the value changes. Fix that. Signed-off-by: Mark Brown --- sound/soc/codecs/max98090.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c index 6d9261346842..62b41ca050a2 100644 --- a/sound/soc/codecs/max98090.c +++ b/sound/soc/codecs/max98090.c @@ -430,7 +430,7 @@ static int max98090_put_enab_tlv(struct snd_kcontrol *kcontrol, mask << mc->shift, sel << mc->shift); - return 0; + return *select != val; } static const char *max98090_perf_pwr_text[] =