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 */