From mboxrd@z Thu Jan 1 00:00:00 1970 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 D3902C433F5 for ; Wed, 23 Feb 2022 14:56: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 0CCBF1A3C; Wed, 23 Feb 2022 15:56:03 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 0CCBF1A3C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1645628213; bh=4bd/dv9LeBYoIH2AVL50bQsZpdKpVad3C1hnh6JLNjg=; h=Date:From:To:Subject:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=OnvYb+DVNqDO5+AQnDZagUOdxLvRY7DAF3UVkhOI3tsd/cjOVJVQJl6Ifo3IpO8om j7OO7cy1gNwjjqtR7Jyhis1C+CapY6pVQ1uh+xId1YRpQWvGSyYYde4thN575J3z1M Ps8TLjStW6QCUf8D7nMRRHwTYNebByTaR4qFefBU= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 7BEACF8019D; Wed, 23 Feb 2022 15:56:02 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 5D4B9F80118; Wed, 23 Feb 2022 15:56:01 +0100 (CET) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 47342F80118 for ; Wed, 23 Feb 2022 15:55:54 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 47342F80118 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="dCoFYXHJ"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="ChEjBgXj" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 1BF251F43D; Wed, 23 Feb 2022 14:55:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1645628154; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=8p03YFSiQNYbmpdsHRPWLLm9yRxaqTmYDt6YPNvOYuc=; b=dCoFYXHJqJOuPfQ10Gjy0smCHzI5UqlCM5C26sm1cHxRdor+0qIaKalp9r9hiL8fff2w84 9iFxafCtJxJYjmEamz3qRAevdF+HLXPWu5MDsyj7cMP+DBgk+ILXMpCrZ6bQRIQdi4fRAo UtbldQu+8dx7TgMm1AbpPymJ6rvxzts= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1645628154; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=8p03YFSiQNYbmpdsHRPWLLm9yRxaqTmYDt6YPNvOYuc=; b=ChEjBgXjp3n30A1chu0JGP69O7X2htRlokSQAwrc2pl01FTpCf6K81aINMpacoD2cDqp9W 1dOvXuaN/rt90BDA== Received: from alsa1.suse.de (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 115FFA3B81; Wed, 23 Feb 2022 14:55:54 +0000 (UTC) Date: Wed, 23 Feb 2022 15:55:54 +0100 Message-ID: From: Takashi Iwai To: Marek Vasut Subject: Re: [PATCH] ASoC: ops: Shift tested values in snd_soc_put_volsw() by +min In-Reply-To: <20220215130645.164025-1-marex@denx.de> References: <20220215130645.164025-1-marex@denx.de> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Cc: alsa-devel@alsa-project.org, Mark Brown , stable@vger.kernel.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" On Tue, 15 Feb 2022 14:06:45 +0100, Marek Vasut wrote: > > While the $val/$val2 values passed in from userspace are always >= 0 > integers, the limits of the control can be signed integers and the $min > can be non-zero and less than zero. To correctly validate $val/$val2 > against platform_max, add the $min offset to val first. > > Fixes: 817f7c9335ec0 ("ASoC: ops: Reject out of bounds values in snd_soc_put_volsw()") > Signed-off-by: Marek Vasut > Cc: Mark Brown > Cc: stable@vger.kernel.org Now I'm looking at this since I pulled Mark's PR, and noticed that snd_soc_put_volsw_sx() may have a similar problem. Care to cover that, too? But, more reading the code, I suspect whether the function does work correctly at all... How is the mask calculation done in that way? unsigned int mask = (1U << (fls(min + max) - 1)) - 1; What's the difference of this function with snd_soc_put_volsw()? Furthermore, the mask calculation and usage in snd_soc_put_volsw() isn't right, either, I'm afraid; if the range is [-10, 0], max=0, then mask will 0, which will omit all values... I guess we need to revisit those functions (or I need more coffee). thanks, Takashi