watchdog: dw_wdt: Read clock rate only once and validate it
commitc97344f73fdc35b27c7315c5e7c5decd4ce10467
authorGuenter Roeck <linux@roeck-us.net>
Wed, 10 Aug 2016 05:35:58 +0000 (9 22:35 -0700)
committerWim Van Sebroeck <wim@iguana.be>
Fri, 23 Sep 2016 06:40:55 +0000 (23 08:40 +0200)
tree4eab86e2fb4499e99dfc741e75127c6b0c6b1a6d
parent2e91838bf7ffdedabdb29e091207d6531d04ef4f
watchdog: dw_wdt: Read clock rate only once and validate it

Coverity reports:

divide_by_zero: In expression readl(dw_wdt->regs + 8) /
clk_get_rate(dw_wdt->clk), division by expression clk_get_rate(dw_wdt->clk)
which may be zero has undefined behavior.

The clock used for the watchdog timer won't change its rate, so read it
only once during probe. Also validate it and abort the probe function
with an error if it is 0.

Cc: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
drivers/watchdog/dw_wdt.c