Skip to content

Commit

Permalink
clk: shmobile: div6: Avoid division by zero in .round_rate()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
geertu authored and Michael Turquette committed Feb 4, 2015
1 parent 039e597 commit 5469d4f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/clk/shmobile/clk-div6.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 5469d4f

Please sign in to comment.