clk: versatile: off by one in clk_sp810_timerclken_of_get()
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 29 Jul 2015 10:17:06 +0000 (13:17 +0300)
committerStephen Boyd <sboyd@codeaurora.org>
Wed, 29 Jul 2015 18:25:23 +0000 (11:25 -0700)
The ">" should be ">=" or we end up reading beyond the end of the array.

Fixes: 6e973d2c4385 ('clk: vexpress: Add separate SP810 driver')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Pawel Moll <pawel.moll@arm.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
drivers/clk/versatile/clk-sp810.c

index 64b0129a0216f3b8d7bb524b7b1688c9c0228d68..7fbe4d4bf35e49d1ee9f19bd989f49b16e16f0ee 100644 (file)
@@ -129,8 +129,8 @@ static struct clk *clk_sp810_timerclken_of_get(struct of_phandle_args *clkspec,
 {
        struct clk_sp810 *sp810 = data;
 
-       if (WARN_ON(clkspec->args_count != 1 || clkspec->args[0] >
-                       ARRAY_SIZE(sp810->timerclken)))
+       if (WARN_ON(clkspec->args_count != 1 ||
+                   clkspec->args[0] >= ARRAY_SIZE(sp810->timerclken)))
                return NULL;
 
        return sp810->timerclken[clkspec->args[0]].clk;