Skip to content

Commit 90b7f9c

Browse files
Telecaster2147Rbb666
authored andcommitted
fix(drivers): validate i6300esb watchdog timeout bounds
1 parent fa0a61c commit 90b7f9c

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

components/drivers/watchdog/watchdog-i6300esb.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ static rt_err_t i6300esb_timer_set_heartbeat(struct i6300esb_wdt *esb, rt_uint32
111111
{
112112
rt_uint32_t val;
113113

114+
if ((time < ESB_HEARTBEAT_MIN) || (time > ESB_HEARTBEAT_MAX))
115+
{
116+
return -RT_EINVAL;
117+
}
118+
114119
/*
115120
* We shift by 9, so if we are passed a value of 1 sec,
116121
* 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)
152157
break;
153158

154159
case RT_DEVICE_CTRL_WDT_SET_TIMEOUT:
160+
if (args == RT_NULL)
161+
{
162+
err = -RT_EINVAL;
163+
break;
164+
}
155165
err = i6300esb_timer_set_heartbeat(esb, *(rt_uint32_t *)args);
156166
break;
157167

0 commit comments

Comments
 (0)