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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user