From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AE16EA59 for ; Mon, 9 Mar 2026 17:45:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773078345; cv=none; b=M+7JFXREyFmpxoKqmAPxFcE5KLW4Jja8XLVJqNewWmCMSr4FSsjRQ/w+tYjXsUzJ0NAJg8l2V4iDZfE2MozEtqZgUn89PSJJ1KYRDKre1/Rammec1auQMnyfS/ZzRlVjhNyhzKswWxRapoVRRewACYF0nUEyDbLBEbXCtDX0kCo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773078345; c=relaxed/simple; bh=FzasR78AWhAA/DbPFYrs6ToZnSFiOQSkC8j91I1OAaw=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Wafcsin6+h67jSMVT8SxRtWo+udz00E1KbMyM28hvKQ9D7JQRRnNoqTfiK4Dzx5+i5E2y72wcCgLNjzuIfWyqRMRjlzYinSZEKK2p0BZcfYl/YmbVqVIO6/SKMHfcTLUj02A9StIcLr6sqTkWo/Jw0eqQJHU1Xx5wh93dJLmyjo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dxbN31cA; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dxbN31cA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C2CB8C4CEF7; Mon, 9 Mar 2026 17:45:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773078345; bh=FzasR78AWhAA/DbPFYrs6ToZnSFiOQSkC8j91I1OAaw=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=dxbN31cAknH8X3Qb41YkE26A9YKZPfQQxFY3ZjX4Wt3T91QqbFqt/c9eliFUkLlvV irAzqxiN/jnWXIa4f/TLdCjJnTbMSaL3Jt8Y8XKwbivNIkJLWIZbpkFJLUdE671agM Ldf9SkkqxdiDOrPj6mYSoCDUZ7C/adD423Y+DxeBfHfRcGniqQFfOK2AtUnUa3xk3i jWFURX/NnExE9+2Sc1HHwhDvBQ05Rie/zP9zmIAsIzT2eLgyO1qdDLZcCuPUF0BhH6 we3Njkcmf75aUYomhRDMyH/2ATP+sewUZnqy4zYy/ydhVjVd72fQfvZrRqyNHSKW56 czkdvfKw5blTQ== Message-ID: Date: Mon, 9 Mar 2026 17:45:41 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/3] ASoC: codecs: wcd9335: Remove potential undefined behavior in wcd9335_slimbus_irq() To: Josh Poimboeuf , x86@kernel.org Cc: linux-kernel@vger.kernel.org, Arnd Bergmann , Peter Zijlstra , Nathan Chancellor , Srinivas Kandagatla , Liam Girdwood , Mark Brown References: <08dbb63519ef31a5457e07673b7b256fecb5989b.1773071992.git.jpoimboe@kernel.org> Content-Language: en-US From: Srinivas Kandagatla In-Reply-To: <08dbb63519ef31a5457e07673b7b256fecb5989b.1773071992.git.jpoimboe@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 3/9/26 4:03 PM, Josh Poimboeuf wrote: > If 'port_id' is negative, the shift counts in wcd9335_slimbus_irq() also > become negative, resulting in undefined behavior due to shift out of > bounds. > > That appears to be not possible, but with UBSAN enabled, Clang's range > analysis isn't always able to determine that and generates undefined > behavior. > > As a result the code generation isn't optimal, and undefined behavior > should be avoided regardless. Improve code generation and remove the > undefined behavior by converting the signed variables to unsigned. > > Fixes the following warning: > > sound/soc/codecs/wcd9335.o: warning: objtool: wcd9335_slimbus_irq() falls through to next function __cfi_wcd9335_set_channel_map() > > This is very similar to a previous fix to wcd934x with commit > 060aed9c0093 ("objtool, ASoC: codecs: wcd934x: Remove potential > undefined behavior in wcd934x_slim_irq_handler()"). > > Cc: Srinivas Kandagatla > Cc: Liam Girdwood > Cc: Mark Brown > Reported-by: Arnd Bergmann > Closes: https://lore.kernel.org/a426d669-58bb-4be1-9eaa-6f3d83109e2d@app.fastmail.com > Signed-off-by: Josh Poimboeuf > --- Am not sure if port_id will be ever negative. but the change itself looks harmless, Reviewed-by: Srinivas Kandagatla --srini > sound/soc/codecs/wcd9335.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/sound/soc/codecs/wcd9335.c b/sound/soc/codecs/wcd9335.c > index 640e43ee1975..e3ca5ca6de3d 100644 > --- a/sound/soc/codecs/wcd9335.c > +++ b/sound/soc/codecs/wcd9335.c > @@ -3907,7 +3907,7 @@ static irqreturn_t wcd9335_slimbus_irq(int irq, void *data) > { > struct wcd9335_codec *wcd = data; > unsigned long status = 0; > - int i, j, port_id; > + unsigned int i, j, port_id; > unsigned int val, int_val = 0; > irqreturn_t ret = IRQ_NONE; > bool tx;