output drivers: init SmartLock after exit_and_cleanup

This fixes an invalid memory access when exiting the module:
exit_and_cleanup destroys the object, but lock_guard is destructed after
and accesses the lock.
This commit is contained in:
Beat Küng
2022-05-12 08:16:35 -04:00
committed by Daniel Agar
parent 0a9378e0f6
commit 9166b6953d
7 changed files with 14 additions and 14 deletions
+2 -2
View File
@@ -439,8 +439,6 @@ bool PWMOut::updateOutputs(bool stop_motors, uint16_t outputs[MAX_ACTUATORS],
void PWMOut::Run()
{
SmartLock lock_guard(_lock);
if (should_exit()) {
ScheduleClear();
_mixing_output.unregister();
@@ -449,6 +447,8 @@ void PWMOut::Run()
return;
}
SmartLock lock_guard(_lock);
perf_begin(_cycle_perf);
perf_count(_interval_perf);