clk: mvebu: Fix valid value range checking for cpu_freq_select
authorAxel Lin <axel.lin@ingics.com>
Mon, 8 Apr 2013 03:43:02 +0000 (11:43 +0800)
committerMike Turquette <mturquette@linaro.org>
Tue, 9 Apr 2013 05:26:36 +0000 (22:26 -0700)
cpu_freq_select is used as array subscript, thus the valid value range
is 0 ... ARRAY_SIZE() - 1.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
[mturquette@linaro.org: fixed up trivial merge issues]

drivers/clk/mvebu/clk-core.c

index 69056a7479e850dc4f3728340f3fa201c025920b..2628610c1929b8dbcd12a04f5ccd0ea3b26214f3 100644 (file)
@@ -156,7 +156,7 @@ static u32 __init armada_370_get_cpu_freq(void __iomem *sar)
 
        cpu_freq_select = ((readl(sar) >> SARL_A370_PCLK_FREQ_OPT) &
                           SARL_A370_PCLK_FREQ_OPT_MASK);
-       if (cpu_freq_select > ARRAY_SIZE(armada_370_cpu_frequencies)) {
+       if (cpu_freq_select >= ARRAY_SIZE(armada_370_cpu_frequencies)) {
                pr_err("CPU freq select unsuported %d\n", cpu_freq_select);
                cpu_freq = 0;
        } else
@@ -278,7 +278,7 @@ static u32 __init armada_xp_get_cpu_freq(void __iomem *sar)
        cpu_freq_select |= (((readl(sar+4) >> SARH_AXP_PCLK_FREQ_OPT) &
                             SARH_AXP_PCLK_FREQ_OPT_MASK)
                            << SARH_AXP_PCLK_FREQ_OPT_SHIFT);
-       if (cpu_freq_select > ARRAY_SIZE(armada_xp_cpu_frequencies)) {
+       if (cpu_freq_select >= ARRAY_SIZE(armada_xp_cpu_frequencies)) {
                pr_err("CPU freq select unsuported: %d\n", cpu_freq_select);
                cpu_freq = 0;
        } else