]> git.ipfire.org Git - thirdparty/kernel/stable.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 14 May 2021 08:49:57 +0000 (10:49 +0200)
commitf35022b7061b9ed67dd4c106c6305156aa37a230
tree3c7231ef56bc256f8d63267e1d83d5509249b4e0
parent1f6205880d0189fb6b80dc93dc745ccd971bfbae
clk: uniphier: Fix potential infinite loop

[ Upstream commit f6b1340dc751a6caa2a0567b667d0f4f4172cd58 ]

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: 734d82f4a678 ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/clk/uniphier/clk-uniphier-mux.c