Skip to content
Permalink
Browse files

drivers: watchdog: sam0: Check if timeout is valid

The upper limit of the timeout should not be 0.
tests/drivers/watchdog/wdt_basic_api checks for this and fails as the
driver currently only checks that the timout does not exceed the upper
bound.
This also makes it check the lower bound, so that the test passes.

Signed-off-by: Benjamin Valentin <benjamin.valentin@ml-pa.com>
  • Loading branch information...
benpicco authored and MaureenHelm committed May 8, 2019
1 parent 37d4947 commit 29deef2def88bb2eaed826a1e2c5ccb23f9698ab
Showing with 5 additions and 0 deletions.
  1. +5 −0 drivers/watchdog/wdt_sam0.c
@@ -117,6 +117,11 @@ static int wdt_sam0_install_timeout(struct device *dev,
return -ENOTSUP;
}

if (cfg->window.max == 0) {
LOG_ERR("Upper limit timeout out of range");
return -EINVAL;
}

per = wdt_sam0_timeout_to_wdt_period(cfg->window.max);
if (per > WDT_CONFIG_PER_16K_Val) {
LOG_ERR("Upper limit timeout out of range");

0 comments on commit 29deef2

Please sign in to comment.
You can’t perform that action at this time.