Re: [PATCH] cpufreq: fix overflow in cpufreq_table_find_index_dl()

From: Sergey Senozhatsky
Date: Mon Oct 17 2016 - 11:21:57 EST


On (10/18/16 00:14), Sergey Senozhatsky wrote:
[..]
> include/linux/cpufreq.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
> index 5fa55fc..2a7aa0b 100644
> --- a/include/linux/cpufreq.h
> +++ b/include/linux/cpufreq.h
> @@ -677,10 +677,10 @@ static inline int cpufreq_table_find_index_dl(struct cpufreq_policy *policy,
> if (best == table - 1)
> return pos - table;
>
> - return best - pos;
> + return pos - best;
> }
>
> - return best - pos;
> + return pos - best;
> }

hmm.., you know what... I'm now actually curious,
why does it do `pos - best' and not `best - table'?

-ss