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

soc: qcom: geni-se: fix array underflow in geni_se_clk_tbl_get()

This loop is supposed to break if the frequency returned from
clk_round_rate() is the same as on the previous iteration. However,
that check doesn't make sense on the first iteration through the loop.
It leads to reading before the start of these->clk_perf_tbl[] array.

Fixes: eddac5af0654 ("soc: qcom: Add GENI based QUP Wrapper driver")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://lore.kernel.org/r/8cd12678-f44a-4b16-a579-c8f11175ee8c@stanley.mountain
Signed-off-by: Bjorn Andersson <andersson@kernel.org>

authored by

Dan Carpenter and committed by
Bjorn Andersson
78261cb0 99b2186b

+2 -1
+2 -1
drivers/soc/qcom/qcom-geni-se.c
··· 585 585 586 586 for (i = 0; i < MAX_CLK_PERF_LEVEL; i++) { 587 587 freq = clk_round_rate(se->clk, freq + 1); 588 - if (freq <= 0 || freq == se->clk_perf_tbl[i - 1]) 588 + if (freq <= 0 || 589 + (i > 0 && freq == se->clk_perf_tbl[i - 1])) 589 590 break; 590 591 se->clk_perf_tbl[i] = freq; 591 592 }