diff options
author | Patrick Rudolph <patrick.rudolph@9elements.com> | 2022-09-09 15:59:53 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2022-10-26 14:25:46 +0300 |
commit | b051d9bf98bd9cea312b228e264eb6542a9beb67 (patch) | |
tree | 3b2a79cc16deac45d4aa2ca614c770b7a95be876 /drivers/regulator | |
parent | e01d96494a9de0f48b1167f0494f6d929fa773ed (diff) | |
download | linux-b051d9bf98bd9cea312b228e264eb6542a9beb67.tar.xz |
regulator: core: Prevent integer underflow
[ Upstream commit 8d8e16592022c9650df8aedfe6552ed478d7135b ]
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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/regulator')
-rw-r--r-- | drivers/regulator/core.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 317d701487ec..bf8ba73d6c7c 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -2544,7 +2544,7 @@ static int _regulator_do_enable(struct regulator_dev *rdev) * expired, return -ETIMEDOUT. */ if (rdev->desc->poll_enabled_time) { - unsigned int time_remaining = delay; + int time_remaining = delay; while (time_remaining > 0) { _regulator_enable_delay(rdev->desc->poll_enabled_time); |