clk: at91: Fix use of unsigned loop index
authorAndrew Goodbody <andrew.goodbody@linaro.org>
Wed, 23 Jul 2025 14:13:49 +0000 (15:13 +0100)
committerEugen Hristev <eugen.hristev@linaro.org>
Wed, 13 Aug 2025 09:59:36 +0000 (12:59 +0300)
commitda13ce8a6b1a37c49d2215ef78ee7984bae1c068
tree8ef8b052c24b68c380dc503a6ad6567051c50231
parent29ea990a1c4a2455f432d5e71b217e93b406fc12
clk: at91: Fix use of unsigned loop index

The use of the unsigned variable 'i' as a loop index leads to the test
for i being non-negative always being true. Instead declare 'i' as an
int so that the for loop will terminate as expected.
If the original for loop completes 'i' will be 1 past the end of the
array so decrement it in the subsequent error path to prevent an out of
bounds access occurring.

This issue was found by Smatch.

Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org>
drivers/clk/at91/sckc.c