[PATCH 2/4] ARM: imx: clocksource: error out if clk freq is 0

Uwe Kleine-König u.kleine-koenig at pengutronix.de
Fri Jul 28 13:08:10 PDT 2017


If instead this isn't checked this results in a division by zero later.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig at pengutronix.de>
---
 arch/arm/mach-imx/clocksource.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/mach-imx/clocksource.c b/arch/arm/mach-imx/clocksource.c
index 17762c3caf25..793f84ee4800 100644
--- a/arch/arm/mach-imx/clocksource.c
+++ b/arch/arm/mach-imx/clocksource.c
@@ -121,6 +121,10 @@ static int imx_gpt_probe(struct device_d *dev)
 		dev_err(dev, "failed to get clock\n");
 	} else {
 		rate = clk_get_rate(clk_gpt);
+		if (!rate) {
+			dev_err(dev, "clock reports rate == 0\n");
+			return -EIO;
+		}
 	}
 
 	writel(0, timer_base + GPT_TPRER);
-- 
2.11.0




More information about the barebox mailing list