Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1573991pxb; Tue, 8 Feb 2022 22:46:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJw7nCabFT4wvlz0gw4vM18sATRnj4/ShwL0FLooEmP7eiA5hmjBcTbTMvXTkJxgNcGBn6E0 X-Received: by 2002:a17:902:db0f:: with SMTP id m15mr1070179plx.158.1644389209922; Tue, 08 Feb 2022 22:46:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644389209; cv=none; d=google.com; s=arc-20160816; b=x3e9Yx6L4uEo1hNOX43KOMN4gS+Zv8vRccBEHxZmkcFWFiGQVm4yzfGoEwpi8lZZ2d fXK+achBZQiAxm7T+UUj9sndBCsNUU/E6lOysScChGWRv1PTXXjJHQ3eJxAc7tdpNCzo EW2jjcSgkwC+cvqC3HrwRpwsDIE4QvSgQpH3uH8v+DqMBMpcG8tR10nzc1YnEy1snzM/ ImmM3kIhuy2mn5EyA50l5OWoVptW2y3GIyYpPMwVmm8IkwQSRuyaqSGs8RhqIONDTwmC Cvcz6M6AhlQHtK5ZShi4RBb7Vu5KKvpu/eVaLFHW63Jz0pHh5jaHm7vWDGSm64ZmxFCr SJoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=pN499x6LTxSwqgAcTzv7tNPGh/7VCB1EcHfNcFbti9E=; b=HcBo5jDmg/tGrMGtAZBaj1XTE5vQ2B846sJvlqCDmAOKPknmdnU6IqnF7NZz57b1AM IzMidRlsdwwgiWWIr7j5VD2UrAp40aa0eFDXmI8aWUzEMHcK23O7mQfYZ2TsgQXwG6i/ 9QXFDezONk4NB9Hj6BF3WIsBx3r2Zs/jObEQfwdMze/NthZsehptBitc9rS0vN1OZUD3 hLCRuCbsmXpXdRC6PVCfx2tfygHQffau5Qv52HYC/NFlQEQgbcsa7IxNc2IcmzCgvIvd R26BBcZ4B3tN6rC6vJs2wMAXA/cdapeuSfZbA/LlSl1LATs0KJ1YLYX6rRHoUAUYIszp d6IA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=A1jAPGWH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f2si3378125pgg.531.2022.02.08.22.46.37; Tue, 08 Feb 2022 22:46:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=A1jAPGWH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1390778AbiBGL54 (ORCPT + 99 others); Mon, 7 Feb 2022 06:57:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384711AbiBGL3j (ORCPT ); Mon, 7 Feb 2022 06:29:39 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B46F4C0401C6; Mon, 7 Feb 2022 03:28:07 -0800 (PST) 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 8FF366091A; Mon, 7 Feb 2022 11:28:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5EAD4C340F0; Mon, 7 Feb 2022 11:28:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233287; bh=07DXET1mUt27c2qdzB5vxavcElMoUr/eGhq3NzQRh/A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A1jAPGWHt+KcZKzX5uwMzPn2N0SERWpjCZgK0c6PLjyGEpFJVX6Ydt/4jfKq0jges 8g4sY8qN1d5VnopwJ7dVZSg6rxk/UyO6DZWyr3met0Uku4oZThfk2a2E5urPRV/wK2 AsGHls+sEe22ha297QRYDnrB4ytt46Lk4JBfMkdw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Mark Brown Subject: [PATCH 5.15 075/110] ASoC: max9759: fix underflow in speaker_gain_control_put() Date: Mon, 7 Feb 2022 12:06:48 +0100 Message-Id: <20220207103804.925662667@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dan Carpenter commit 4c907bcd9dcd233da6707059d777ab389dcbd964 upstream. Check for negative values of "priv->gain" to prevent an out of bounds access. The concern is that these might come from the user via: -> snd_ctl_elem_write_user() -> snd_ctl_elem_write() -> kctl->put() Fixes: fa8d915172b8 ("ASoC: max9759: Add Amplifier Driver") Signed-off-by: Dan Carpenter Link: https://lore.kernel.org/r/20220119123101.GA9509@kili Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman --- sound/soc/codecs/max9759.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/sound/soc/codecs/max9759.c +++ b/sound/soc/codecs/max9759.c @@ -64,7 +64,8 @@ static int speaker_gain_control_put(stru struct snd_soc_component *c = snd_soc_kcontrol_component(kcontrol); struct max9759 *priv = snd_soc_component_get_drvdata(c); - if (ucontrol->value.integer.value[0] > 3) + if (ucontrol->value.integer.value[0] < 0 || + ucontrol->value.integer.value[0] > 3) return -EINVAL; priv->gain = ucontrol->value.integer.value[0];