Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

regulator: core: Prevent integer underflow

By using a ratio of delay to poll_enabled_time that is not integer
time_remaining underflows and does not exit the loop as expected.
As delay could be derived from DT and poll_enabled_time is defined
in the driver this can easily happen.

Use a signed iterator to make sure that the loop exits once
the remaining time is negative.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Link: https://lore.kernel.org/r/20220909125954.577669-1-patrick.rudolph@9elements.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Patrick Rudolph and committed by
Mark Brown
8d8e1659 08865c21

+1 -1
+1 -1
drivers/regulator/core.c
··· 2699 2699 * return -ETIMEDOUT. 2700 2700 */ 2701 2701 if (rdev->desc->poll_enabled_time) { 2702 - unsigned int time_remaining = delay; 2702 + int time_remaining = delay; 2703 2703 2704 2704 while (time_remaining > 0) { 2705 2705 _regulator_delay_helper(rdev->desc->poll_enabled_time);