Skip to content

Commit f6b1340

Browse files
Colin Ian Kingbebarino
authored andcommitted
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: 734d82f ("clk: uniphier: add core support code for UniPhier clock driver") Signed-off-by: Colin Ian King <[email protected]> Reviewed-by: Masahiro Yamada <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Stephen Boyd <[email protected]>
1 parent a38fd87 commit f6b1340

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/clk/uniphier/clk-uniphier-mux.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ static int uniphier_clk_mux_set_parent(struct clk_hw *hw, u8 index)
3131
static u8 uniphier_clk_mux_get_parent(struct clk_hw *hw)
3232
{
3333
struct uniphier_clk_mux *mux = to_uniphier_clk_mux(hw);
34-
int num_parents = clk_hw_get_num_parents(hw);
34+
unsigned int num_parents = clk_hw_get_num_parents(hw);
3535
int ret;
3636
unsigned int val;
37-
u8 i;
37+
unsigned int i;
3838

3939
ret = regmap_read(mux->regmap, mux->reg, &val);
4040
if (ret)

0 commit comments

Comments
 (0)