Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

watchdog: atlas7_wdt: test clock rate to avoid division by 0

The clk API may return 0 on clk_get_rate, so we should check the result before
using it as a divisor.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>

authored by

Wolfram Sang and committed by
Wim Van Sebroeck
ccc8208d 882dec1f

+5
+5
drivers/watchdog/atlas7_wdt.c
··· 154 154 writel(0, wdt->base + ATLAS7_WDT_CNT_CTRL); 155 155 156 156 wdt->tick_rate = clk_get_rate(clk); 157 + if (!wdt->tick_rate) { 158 + ret = -EINVAL; 159 + goto err1; 160 + } 161 + 157 162 wdt->clk = clk; 158 163 atlas7_wdd.min_timeout = 1; 159 164 atlas7_wdd.max_timeout = UINT_MAX / wdt->tick_rate;