Эх сурвалжийг харах

clk: shmobile: div6: Avoid division by zero in .round_rate()

Anyone may call clk_round_rate() with a zero rate value, so we have to
protect against that.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Michael Turquette <mturquette@linaro.org>
Geert Uytterhoeven 10 жил өмнө
parent
commit
5469d4f22e

+ 3 - 0
drivers/clk/shmobile/clk-div6.c

@@ -90,6 +90,9 @@ static unsigned int cpg_div6_clock_calc_div(unsigned long rate,
 {
 {
 	unsigned int div;
 	unsigned int div;
 
 
+	if (!rate)
+		rate = 1;
+
 	div = DIV_ROUND_CLOSEST(parent_rate, rate);
 	div = DIV_ROUND_CLOSEST(parent_rate, rate);
 	return clamp_t(unsigned int, div, 1, 64);
 	return clamp_t(unsigned int, div, 1, 64);
 }
 }