2020-01-10 17:48:46

by Ikjoon Jang

[permalink] [raw]
Subject: [PATCH] cpuidle: teo: bugfix in intervals[] array indexing

Fix a simple bug in rotating array index.

Signed-off-by: Ikjoon Jang <[email protected]>
---
drivers/cpuidle/governors/teo.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/cpuidle/governors/teo.c b/drivers/cpuidle/governors/teo.c
index de7e706efd46..6deaaf5f05b5 100644
--- a/drivers/cpuidle/governors/teo.c
+++ b/drivers/cpuidle/governors/teo.c
@@ -198,7 +198,7 @@ static void teo_update(struct cpuidle_driver *drv, struct cpuidle_device *dev)
* pattern detection.
*/
cpu_data->intervals[cpu_data->interval_idx++] = measured_ns;
- if (cpu_data->interval_idx > INTERVALS)
+ if (cpu_data->interval_idx >= INTERVALS)
cpu_data->interval_idx = 0;
}

--
2.25.0.rc1.283.g88dfdc4193-goog


2020-01-13 10:46:18

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH] cpuidle: teo: bugfix in intervals[] array indexing

On Fri, Jan 10, 2020 at 6:47 PM Ikjoon Jang <[email protected]> wrote:
>
> Fix a simple bug in rotating array index.
>
> Signed-off-by: Ikjoon Jang <[email protected]>
> ---
> drivers/cpuidle/governors/teo.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/cpuidle/governors/teo.c b/drivers/cpuidle/governors/teo.c
> index de7e706efd46..6deaaf5f05b5 100644
> --- a/drivers/cpuidle/governors/teo.c
> +++ b/drivers/cpuidle/governors/teo.c
> @@ -198,7 +198,7 @@ static void teo_update(struct cpuidle_driver *drv, struct cpuidle_device *dev)
> * pattern detection.
> */
> cpu_data->intervals[cpu_data->interval_idx++] = measured_ns;
> - if (cpu_data->interval_idx > INTERVALS)
> + if (cpu_data->interval_idx >= INTERVALS)
> cpu_data->interval_idx = 0;
> }
>
> --

Applied as a fix for 5,5 and "stable", thanks!