]> git.baikalelectronics.ru Git - kernel.git/commit
clk: uniphier: Fix potential infinite loop
authorColin Ian King <colin.king@canonical.com>
Fri, 9 Apr 2021 09:01:03 +0000 (10:01 +0100)
committerStephen Boyd <sboyd@kernel.org>
Tue, 13 Apr 2021 02:09:59 +0000 (19:09 -0700)
commit1da5e6b8f3bb293ef656bdb658c768a4583871af
tree63ce5ae4386771ca079a12f18e9aa781d7ee19b4
parent1b8bd930b05ba1f659bccfc6ef406e93916f57ed
clk: uniphier: Fix potential infinite loop

The for-loop iterates with a u8 loop counter i and compares this
with the loop upper limit of num_parents that is an int type.
There is a potential infinite loop if num_parents is larger than
the u8 loop counter. Fix this by making the loop counter the same
type as num_parents.  Also make num_parents an unsigned int to
match the return type of the call to clk_hw_get_num_parents.

Addresses-Coverity: ("Infinite loop")
Fixes: 853694d944f8 ("clk: uniphier: add core support code for UniPhier clock driver")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Masahiro Yamada <masahiroy@kernel.org>
Link: https://lore.kernel.org/r/20210409090104.629722-1-colin.king@canonical.com
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
drivers/clk/uniphier/clk-uniphier-mux.c