[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1423052841-15194-1-git-send-email-geert+renesas@glider.be>
Date: Wed, 4 Feb 2015 13:27:21 +0100
From: Geert Uytterhoeven <geert+renesas@...der.be>
To: Mike Turquette <mturquette@...aro.org>,
Stephen Boyd <sboyd@...eaurora.org>
Cc: Laurent Pinchart <laurent.pinchart@...asonboard.com>,
Ulrich Hecht <ulrich.hecht+renesas@...il.com>,
Wolfram Sang <wsa@...g-engineering.com>,
linux-sh@...r.kernel.org, linux-kernel@...r.kernel.org,
Geert Uytterhoeven <geert+renesas@...der.be>
Subject: [PATCH] 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@...der.be>
---
This was triggered by the bad version of "clk: Add rate constraints to
clocks", but can happen regardless, cfr.
https://lkml.org/lkml/2015/1/29/560
drivers/clk/shmobile/clk-div6.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/clk/shmobile/clk-div6.c b/drivers/clk/shmobile/clk-div6.c
index efbaf6c81b7530b8..036a692c72195db9 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);
}
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists