Skip to content

Commit

Permalink
watchdog: atlas7_wdt: test clock rate to avoid division by 0
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Wolfram Sang authored and Wim Van Sebroeck committed Mar 16, 2016
1 parent 882dec1 commit ccc8208
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/watchdog/atlas7_wdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@ static int atlas7_wdt_probe(struct platform_device *pdev)
writel(0, wdt->base + ATLAS7_WDT_CNT_CTRL);

wdt->tick_rate = clk_get_rate(clk);
if (!wdt->tick_rate) {
ret = -EINVAL;
goto err1;
}

wdt->clk = clk;
atlas7_wdd.min_timeout = 1;
atlas7_wdd.max_timeout = UINT_MAX / wdt->tick_rate;
Expand Down

0 comments on commit ccc8208

Please sign in to comment.