Skip to content

Commit 29c578c

Browse files
jpoimboeIngo Molnar
authored andcommitted
objtool, regulator: rk808: Remove potential undefined behavior in rk806_set_mode_dcdc()
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 <[email protected]> Signed-off-by: Josh Poimboeuf <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Acked-by: Mark Brown <[email protected]> Cc: Liam Girdwood <[email protected]> Cc: Linus Torvalds <[email protected]> Link: https://lore.kernel.org/r/2023abcddf3f524ba478d64339996f25dc4097d2.1742852847.git.jpoimboe@kernel.org Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
1 parent 060aed9 commit 29c578c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/regulator/rk808-regulator.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,8 @@ static const unsigned int rk817_buck1_4_ramp_table[] = {
270270

271271
static int rk806_set_mode_dcdc(struct regulator_dev *rdev, unsigned int mode)
272272
{
273-
int rid = rdev_get_id(rdev);
274-
int ctr_bit, reg;
273+
unsigned int rid = rdev_get_id(rdev);
274+
unsigned int ctr_bit, reg;
275275

276276
reg = RK806_POWER_FPWM_EN0 + rid / 8;
277277
ctr_bit = rid % 8;

0 commit comments

Comments
 (0)