Skip to content

Commit

Permalink
HAL_ChibiOS: protect chEvtSignal from null waiter
Browse files Browse the repository at this point in the history
This fixes #29370
  • Loading branch information
tridge committed Feb 25, 2025
1 parent 0fb627f commit cb67ae5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
5 changes: 3 additions & 2 deletions libraries/AP_HAL_ChibiOS/RCOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1842,10 +1842,11 @@ __RAMFUNC__ void RCOutput::dma_unlock(virtual_timer_t* vt, void *p)
pwm_group *group = (pwm_group *)p;

group->dshot_state = DshotState::IDLE;
if (group->dshot_waiter != nullptr) {
auto *waiter = group->dshot_waiter;
if (waiter != nullptr) {
// tell the waiting process we've done the DMA. Note that
// dshot_waiter can be null if we have cancelled the send
chEvtSignalI(group->dshot_waiter, group->dshot_event_mask);
chEvtSignalI(waiter, group->dshot_event_mask);
}
chSysUnlockFromISR();
}
Expand Down
12 changes: 9 additions & 3 deletions libraries/AP_HAL_ChibiOS/RCOutput_bdshot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -515,8 +515,11 @@ __RAMFUNC__ void RCOutput::bdshot_finish_dshot_gcr_transaction(virtual_timer_t*
// although it should be possible to start the next DMAR transaction concurrently with receiving
// telemetry, in practice it seems to interfere with the DMA engine
if (group->shared_up_dma && group->bdshot.enabled) {
// next dshot pulse can go out now
chEvtSignalI(group->dshot_waiter, DSHOT_CASCADE);
auto *waiter = group->dshot_waiter;
if (waiter != nullptr) {
// next dshot pulse can go out now
chEvtSignalI(waiter, DSHOT_CASCADE);
}
}
#endif
// if using input capture DMA and sharing the UP and CH channels then clean up
Expand All @@ -541,7 +544,10 @@ __RAMFUNC__ void RCOutput::bdshot_finish_dshot_gcr_transaction(virtual_timer_t*
}

// tell the waiting process we've done the DMA
chEvtSignalI(group->dshot_waiter, group->dshot_event_mask);
auto *waiter = group->dshot_waiter;
if (waiter != nullptr) {
chEvtSignalI(waiter, group->dshot_event_mask);
}
#ifdef HAL_GPIO_LINE_GPIO56
TOGGLE_PIN_DEBUG(56);
#endif
Expand Down

0 comments on commit cb67ae5

Please sign in to comment.