watchdog: dw_wdt: fix array out-of-bounds in theory

Change-Id: Ie11b60cf79b4c988af1ca7939334cbb742582247
Signed-off-by: Simon Xue <xxm@rock-chips.com>
This commit is contained in:
Simon Xue
2023-11-15 17:34:21 +08:00
committed by Tao Huang
parent 077c5b13fa
commit e8cea8fe67
+7
View File
@@ -156,6 +156,10 @@ static unsigned int dw_wdt_get_min_timeout(struct dw_wdt *dw_wdt)
break;
}
/* For Coverity check */
if (idx == DW_WDT_NUM_TOPS)
idx = 0;
return dw_wdt->timeouts[idx].sec;
}
@@ -179,6 +183,9 @@ static unsigned int dw_wdt_get_timeout(struct dw_wdt *dw_wdt)
break;
}
if (idx == DW_WDT_NUM_TOPS)
idx = 0;
/*
* In IRQ mode due to the two stages counter, the actual timeout is
* twice greater than the TOP setting.