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 E885E258CE7; Mon, 7 Apr 2025 18:12:14 +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=1744049535; cv=none; b=njIPOp8c6KX0UpdNDdw2G5dO9OrPEjanVWP0ao6XTC4SbA0BNCuNm781zGFz/ApY6lgGh53uCnTIx6dKqTMihGWvACf38umValgmw4ZG34dOKyTUzvfOkkRPQX7I9aVVfRCZQC2O3OFhjvRq1FYEit75EiNqDU7SLm8JuBN3JQc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744049535; c=relaxed/simple; bh=o66Zs7GApMNs4fUuUIl+NpS0WXNlG3jWsczt+JCtzj4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=W4oeXbwsT7p7C2Jb5O1snQO3OVbHY5FixzovN2HWG25+oucWcnJAYU2yQhjQ+4v7E9+FflCkCFyODSAgPitKVNjLJoP9ZgyXerp93j22q5RZVA4VpnbRD6OfGuBgjI8iQMQPjOaVHdiL7SWaaBZxHyCnXxuPHq+Uf8yeF504JMg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NxWKsOEw; 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="NxWKsOEw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BF46EC4CEDD; Mon, 7 Apr 2025 18:12:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1744049534; bh=o66Zs7GApMNs4fUuUIl+NpS0WXNlG3jWsczt+JCtzj4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NxWKsOEw0jGCSBLt9uzBOeX3ejXp6Y/bFSB7ObtJrFh+AZjhAbnblf9sGIbudj9bQ YCcLjGj5F7/7RhTIn4wUpcVGU2nlToThDq36RLt9/uyZe6D4ipbP3dFyEP5TBLKDHN 6y0csxUgTep2mgntVUQe1QCg8pFO3xKz5IyHd+xWqNwjL6SgbfsS+g+aOYpp7rXhVt EicN6y63JSMrvbCuArFRp2zV6aoMrmjR97ecp56evWlUVeN3T5YM6gycYX5H856wsX nfZBiiTRVpF/HlQ+HNbC/riTwslgwK0pCK0Wsl5hqxD5c00DK9H9Th5ks9Yt8Ce9E1 ArL4P2FO+ovXg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Josh Poimboeuf , kernel test robot , Ingo Molnar , Mark Brown , Srinivas Kandagatla , Liam Girdwood , Jaroslav Kysela , Takashi Iwai , Linus Torvalds , Sasha Levin , nathan@kernel.org, linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org, llvm@lists.linux.dev Subject: [PATCH AUTOSEL 6.14 29/31] objtool, ASoC: codecs: wcd934x: Remove potential undefined behavior in wcd934x_slim_irq_handler() Date: Mon, 7 Apr 2025 14:10:45 -0400 Message-Id: <20250407181054.3177479-29-sashal@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250407181054.3177479-1-sashal@kernel.org> References: <20250407181054.3177479-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.14.1 Content-Transfer-Encoding: 8bit From: Josh Poimboeuf [ Upstream commit 060aed9c0093b341480770457093449771cf1496 ] If 'port_id' is negative, the shift counts in wcd934x_slim_irq_handler() also become negative, resulting in undefined behavior due to shift out of bounds. If I'm reading the code correctly, that appears to be not possible, but with KCOV 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 with UBSAN: sound/soc/codecs/snd-soc-wcd934x.o: warning: objtool: .text.wcd934x_slim_irq_handler: unexpected end of section Reported-by: kernel test robot Signed-off-by: Josh Poimboeuf Signed-off-by: Ingo Molnar Acked-by: Mark Brown Cc: Srinivas Kandagatla Cc: Liam Girdwood Cc: Jaroslav Kysela Cc: Takashi Iwai Cc: Linus Torvalds Link: https://lore.kernel.org/r/7e863839ec7301bf9c0f429a03873d44e484c31c.1742852847.git.jpoimboe@kernel.org Closes: https://lore.kernel.org/oe-kbuild-all/202503180044.oH9gyPeg-lkp@intel.com/ Signed-off-by: Sasha Levin --- sound/soc/codecs/wcd934x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/codecs/wcd934x.c b/sound/soc/codecs/wcd934x.c index 910852eb9698c..c7f1b28f3b230 100644 --- a/sound/soc/codecs/wcd934x.c +++ b/sound/soc/codecs/wcd934x.c @@ -2273,7 +2273,7 @@ static irqreturn_t wcd934x_slim_irq_handler(int irq, void *data) { struct wcd934x_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; -- 2.39.5