summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAFWEF_147 <[email protected]>2026-04-04 01:59:06 +0000
committerRbb666 <[email protected]>2026-04-22 20:17:01 +0800
commit90b7f9cb0dde49d0d3cb082a709b94cf32899e13 (patch)
tree69b996834776928b643bdc7a08ecc170a34b7288
parentfa0a61c45bbdc8d7a0173069d74fbfab4631c908 (diff)
fix(drivers): validate i6300esb watchdog timeout bounds
-rw-r--r--components/drivers/watchdog/watchdog-i6300esb.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/components/drivers/watchdog/watchdog-i6300esb.c b/components/drivers/watchdog/watchdog-i6300esb.c
index 6a792820b2..6d4867ee5d 100644
--- a/components/drivers/watchdog/watchdog-i6300esb.c
+++ b/components/drivers/watchdog/watchdog-i6300esb.c
@@ -111,6 +111,11 @@ static rt_err_t i6300esb_timer_set_heartbeat(struct i6300esb_wdt *esb, rt_uint32
{
rt_uint32_t val;
+ if ((time < ESB_HEARTBEAT_MIN) || (time > ESB_HEARTBEAT_MAX))
+ {
+ return -RT_EINVAL;
+ }
+
/*
* We shift by 9, so if we are passed a value of 1 sec,
* val will be 1 << 9 = 512, then write that to two
@@ -152,6 +157,11 @@ static rt_err_t i6300esb_wdt_control(rt_watchdog_t *wdt, int cmd, void *args)
break;
case RT_DEVICE_CTRL_WDT_SET_TIMEOUT:
+ if (args == RT_NULL)
+ {
+ err = -RT_EINVAL;
+ break;
+ }
err = i6300esb_timer_set_heartbeat(esb, *(rt_uint32_t *)args);
break;