From: Hangyu Hua Date: Wed, 18 May 2022 06:25:37 +0000 (+0800) Subject: clk: ux500: fix a possible off-by-one in u8500_prcc_reset_base() X-Git-Tag: v5.19-rc1~117^2~2^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bea0b66efa654aee810d0f1791e8f3264bbc2eb9;p=thirdparty%2Flinux.git clk: ux500: fix a possible off-by-one in u8500_prcc_reset_base() 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 Link: https://lore.kernel.org/r/20220518062537.17933-1-hbh25y@gmail.com Reviewed-by: Linus Walleij Signed-off-by: Stephen Boyd --- diff --git a/drivers/clk/ux500/reset-prcc.c b/drivers/clk/ux500/reset-prcc.c index fcd5d042806a6..f7e48941fbc70 100644 --- a/drivers/clk/ux500/reset-prcc.c +++ b/drivers/clk/ux500/reset-prcc.c @@ -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];