From: Geert Uytterhoeven Date: Wed, 4 Feb 2015 12:27:21 +0000 (+0100) Subject: clk: shmobile: div6: Avoid division by zero in .round_rate() X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=5469d4f22e0c18fc5499b11269d2c528094bcf1e;p=linux-beck.git 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 Acked-by: Wolfram Sang Signed-off-by: Michael Turquette --- diff --git a/drivers/clk/shmobile/clk-div6.c b/drivers/clk/shmobile/clk-div6.c index efbaf6c81b75..036a692c7219 100644 --- a/drivers/clk/shmobile/clk-div6.c +++ b/drivers/clk/shmobile/clk-div6.c @@ -90,6 +90,9 @@ static unsigned int cpg_div6_clock_calc_div(unsigned long rate, { unsigned int div; + if (!rate) + rate = 1; + div = DIV_ROUND_CLOSEST(parent_rate, rate); return clamp_t(unsigned int, div, 1, 64); }