mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-22 14:24:21 +08:00
io_timer: fix potential invalid memory access
This commit is contained in:
@@ -525,7 +525,7 @@ void io_timer_trigger(void)
|
||||
|
||||
irqstate_t flags = px4_enter_critical_section();
|
||||
|
||||
for (actions = 0; action_cache[actions] != 0 && actions < MAX_IO_TIMERS; actions++) {
|
||||
for (actions = 0; actions < MAX_IO_TIMERS && action_cache[actions] != 0; actions++) {
|
||||
_REG32(action_cache[actions], KINETIS_FTM_SYNC_OFFSET) |= FTM_SYNC;
|
||||
}
|
||||
|
||||
|
||||
@@ -559,7 +559,7 @@ void io_timer_trigger(void)
|
||||
|
||||
irqstate_t flags = px4_enter_critical_section();
|
||||
|
||||
for (actions = 0; action_cache[actions] != 0 && actions < MAX_IO_TIMERS; actions++) {
|
||||
for (actions = 0; actions < MAX_IO_TIMERS && action_cache[actions] != 0; actions++) {
|
||||
_REG32(action_cache[actions], STM32_GTIM_EGR_OFFSET) |= GTIM_EGR_UG;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user