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 73A6F188A0E; Tue, 29 Apr 2025 18:16:30 +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=1745950590; cv=none; b=M2/dR9FZsZWJR8qb9k4TxVfYY7qR9f1oOiLUi71F/ALpehyv+WiUmE+a65zbVpnxzhFGT480u4+5Gy8ABWLtpnURLgJFRW58v475tQzJF4dmpbHRoqzN3xg+bNFaeTRDp2w+ArvZznbHWp2JUAYeQd2k2dL2cbwJobbsscUvTp0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745950590; c=relaxed/simple; bh=xRsfjBcQpK+8F87NdRM/p+keLMJ1vc55dg6GeeUnDlk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cEXZewfhDfY12Hc/kYkbW1N4p2abXx9K3IPbUs+RcyADqY67W48wikVAMkRzRoPLiUN6xB/nCsdlht/nk10NZW3ZdrhQw665wQBr9iK7CuwzPcu6hgsQ1Mp9phJTxkak2zjD3q9qIINQ9Jz7E4bl4+85Qm8NrHenvrVa7JCbtuo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=AoxZw94Y; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="AoxZw94Y" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EDBFBC4CEE9; Tue, 29 Apr 2025 18:16:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1745950590; bh=xRsfjBcQpK+8F87NdRM/p+keLMJ1vc55dg6GeeUnDlk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AoxZw94Y5WEeYzynv8pnxbrKbr66/A7RJWSbN5MtSfrFAtXL2MqIIy5HaCB8cwzb5 1eUJ0GbYFYUDxV6Jjg30Txg9V1/jYHH8XrfcGQ7F2MKMlb16d8WL6lQNsf6aAN2wPc C8WoZGdIF0Z4qM5zdcFmjaFVcr70eOMpqKoeD4yM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, kernel test robot , Josh Poimboeuf , Ingo Molnar , Mark Brown , Liam Girdwood , Linus Torvalds , Sasha Levin Subject: [PATCH 6.6 144/204] objtool, regulator: rk808: Remove potential undefined behavior in rk806_set_mode_dcdc() Date: Tue, 29 Apr 2025 18:43:52 +0200 Message-ID: <20250429161105.319242030@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250429161059.396852607@linuxfoundation.org> References: <20250429161059.396852607@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Josh Poimboeuf [ Upstream commit 29c578c848402a34e8c8e115bf66cb6008b77062 ] If 'ctr_bit' is negative, the shift counts become negative, causing a shift of bounds and undefined behavior. Presumably that's not possible in normal operation, but 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 an UBSAN kernel: vmlinux.o: warning: objtool: rk806_set_mode_dcdc() falls through to next function rk806_get_mode_dcdc() vmlinux.o: warning: objtool: .text.rk806_set_mode_dcdc: unexpected end of section Reported-by: kernel test robot Signed-off-by: Josh Poimboeuf Signed-off-by: Ingo Molnar Acked-by: Mark Brown Cc: Liam Girdwood Cc: Linus Torvalds Link: https://lore.kernel.org/r/2023abcddf3f524ba478d64339996f25dc4097d2.1742852847.git.jpoimboe@kernel.org Closes: https://lore.kernel.org/oe-kbuild-all/202503182350.52KeHGD4-lkp@intel.com/ Signed-off-by: Sasha Levin --- drivers/regulator/rk808-regulator.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/regulator/rk808-regulator.c b/drivers/regulator/rk808-regulator.c index 374d80dc6d17a..bec22a001a5dd 100644 --- a/drivers/regulator/rk808-regulator.c +++ b/drivers/regulator/rk808-regulator.c @@ -267,8 +267,8 @@ static const unsigned int rk817_buck1_4_ramp_table[] = { static int rk806_set_mode_dcdc(struct regulator_dev *rdev, unsigned int mode) { - int rid = rdev_get_id(rdev); - int ctr_bit, reg; + unsigned int rid = rdev_get_id(rdev); + unsigned int ctr_bit, reg; reg = RK806_POWER_FPWM_EN0 + rid / 8; ctr_bit = rid % 8; -- 2.39.5