Skip to content

Commit c2910c0

Browse files
claudiubezneabebarino
authored andcommitted
clk: at91: clk-master: check if div or pres is zero
Check if div or pres is zero before using it as argument for ffs(). In case div is zero ffs() will return 0 and thus substracting from zero will lead to invalid values to be setup in registers. Fixes: 7a110b9 ("clk: at91: clk-master: re-factor master clock") Fixes: 75c8814 ("clk: at91: clk-master: add master clock support for SAMA7G5") Signed-off-by: Claudiu Beznea <[email protected]> Link: https://lore.kernel.org/r/[email protected] Acked-by: Nicolas Ferre <[email protected]> Signed-off-by: Stephen Boyd <[email protected]>
1 parent f12d028 commit c2910c0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/clk/at91/clk-master.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ static int clk_master_pres_set_rate(struct clk_hw *hw, unsigned long rate,
344344

345345
else if (pres == 3)
346346
pres = MASTER_PRES_MAX;
347-
else
347+
else if (pres)
348348
pres = ffs(pres) - 1;
349349

350350
spin_lock_irqsave(master->lock, flags);
@@ -757,7 +757,7 @@ static int clk_sama7g5_master_set_rate(struct clk_hw *hw, unsigned long rate,
757757

758758
if (div == 3)
759759
div = MASTER_PRES_MAX;
760-
else
760+
else if (div)
761761
div = ffs(div) - 1;
762762

763763
spin_lock_irqsave(master->lock, flags);

0 commit comments

Comments
 (0)