clk: ux500: fix a possible off-by-one in u8500_prcc_reset_base()
authorHangyu Hua <hbh25y@gmail.com>
Wed, 18 May 2022 06:25:37 +0000 (14:25 +0800)
committerStephen Boyd <sboyd@kernel.org>
Wed, 18 May 2022 20:34:03 +0000 (13:34 -0700)
Off-by-one will happen when index == ARRAY_SIZE(ur->base).

Fixes: b14cbdfd467d ("clk: ux500: Add driver for the reset portions of PRCC")
Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
Link: https://lore.kernel.org/r/20220518062537.17933-1-hbh25y@gmail.com
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
drivers/clk/ux500/reset-prcc.c

index fcd5d04..f7e4894 100644 (file)
@@ -58,7 +58,7 @@ static void __iomem *u8500_prcc_reset_base(struct u8500_prcc_reset *ur,
        prcc_num = id / PRCC_PERIPHS_PER_CLUSTER;
        index = prcc_num_to_index(prcc_num);
 
-       if (index > ARRAY_SIZE(ur->base))
+       if (index >= ARRAY_SIZE(ur->base))
                return NULL;
 
        return ur->base[index];