Skip to content

Commit 8d8e165

Browse files
PatrickRudolphbroonie
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 08865c2 commit 8d8e165

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/regulator/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2699,7 +2699,7 @@ static int _regulator_do_enable(struct regulator_dev *rdev)
26992699
* return -ETIMEDOUT.
27002700
*/
27012701
if (rdev->desc->poll_enabled_time) {
2702-
unsigned int time_remaining = delay;
2702+
int time_remaining = delay;
27032703

27042704
while (time_remaining > 0) {
27052705
_regulator_delay_helper(rdev->desc->poll_enabled_time);

0 commit comments

Comments
 (0)