Browse Source

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.
main
Beat Küng 3 years ago committed by Daniel Agar
parent
commit
9166b6953d
  1. 4
      src/drivers/dshot/DShot.cpp
  2. 4
      src/drivers/linux_pwm_out/linux_pwm_out.cpp
  3. 4
      src/drivers/pca9685_pwm_out/main.cpp
  4. 4
      src/drivers/pwm_out/PWMOut.cpp
  5. 4
      src/drivers/pwm_out_sim/PWMSim.cpp
  6. 4
      src/drivers/px4io/px4io.cpp
  7. 4
      src/drivers/tap_esc/TAP_ESC.cpp

4
src/drivers/dshot/DShot.cpp

@ -498,8 +498,6 @@ bool DShot::updateOutputs(bool stop_motors, uint16_t outputs[MAX_ACTUATORS], @@ -498,8 +498,6 @@ bool DShot::updateOutputs(bool stop_motors, uint16_t outputs[MAX_ACTUATORS],
void DShot::Run()
{
SmartLock lock_guard(_lock);
if (should_exit()) {
ScheduleClear();
_mixing_output.unregister();
@ -508,6 +506,8 @@ void DShot::Run() @@ -508,6 +506,8 @@ void DShot::Run()
return;
}
SmartLock lock_guard(_lock);
perf_begin(_cycle_perf);
_mixing_output.update();

4
src/drivers/linux_pwm_out/linux_pwm_out.cpp

@ -126,8 +126,6 @@ bool LinuxPWMOut::updateOutputs(bool stop_motors, uint16_t outputs[MAX_ACTUATORS @@ -126,8 +126,6 @@ bool LinuxPWMOut::updateOutputs(bool stop_motors, uint16_t outputs[MAX_ACTUATORS
void LinuxPWMOut::Run()
{
SmartLock lock_guard(_lock);
if (should_exit()) {
ScheduleClear();
_mixing_output.unregister();
@ -136,6 +134,8 @@ void LinuxPWMOut::Run() @@ -136,6 +134,8 @@ void LinuxPWMOut::Run()
return;
}
SmartLock lock_guard(_lock);
perf_begin(_cycle_perf);
perf_count(_interval_perf);

4
src/drivers/pca9685_pwm_out/main.cpp

@ -376,8 +376,6 @@ bool PCA9685Wrapper::updateOutputs(bool stop_motors, uint16_t *outputs, unsigned @@ -376,8 +376,6 @@ bool PCA9685Wrapper::updateOutputs(bool stop_motors, uint16_t *outputs, unsigned
void PCA9685Wrapper::Run()
{
SmartLock lock_guard(_lock);
if (should_exit()) {
ScheduleClear();
_mixing_output.unregister();
@ -391,6 +389,8 @@ void PCA9685Wrapper::Run() @@ -391,6 +389,8 @@ void PCA9685Wrapper::Run()
return;
}
SmartLock lock_guard(_lock);
perf_begin(_cycle_perf);
switch (_state) {

4
src/drivers/pwm_out/PWMOut.cpp

@ -439,8 +439,6 @@ bool PWMOut::updateOutputs(bool stop_motors, uint16_t outputs[MAX_ACTUATORS], @@ -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() @@ -449,6 +447,8 @@ void PWMOut::Run()
return;
}
SmartLock lock_guard(_lock);
perf_begin(_cycle_perf);
perf_count(_interval_perf);

4
src/drivers/pwm_out_sim/PWMSim.cpp

@ -58,8 +58,6 @@ PWMSim::PWMSim(bool hil_mode_enabled) : @@ -58,8 +58,6 @@ PWMSim::PWMSim(bool hil_mode_enabled) :
void
PWMSim::Run()
{
SmartLock lock_guard(_lock);
if (should_exit()) {
ScheduleClear();
_mixing_output.unregister();
@ -68,6 +66,8 @@ PWMSim::Run() @@ -68,6 +66,8 @@ PWMSim::Run()
return;
}
SmartLock lock_guard(_lock);
_mixing_output.update();
// check for parameter updates

4
src/drivers/px4io/px4io.cpp

@ -525,8 +525,6 @@ void PX4IO::updateFailsafe() @@ -525,8 +525,6 @@ void PX4IO::updateFailsafe()
void PX4IO::Run()
{
SmartLock lock_guard(_lock);
if (should_exit()) {
ScheduleClear();
_mixing_output.unregister();
@ -535,6 +533,8 @@ void PX4IO::Run() @@ -535,6 +533,8 @@ void PX4IO::Run()
return;
}
SmartLock lock_guard(_lock);
perf_begin(_cycle_perf);
perf_count(_interval_perf);

4
src/drivers/tap_esc/TAP_ESC.cpp

@ -329,8 +329,6 @@ bool TAP_ESC::updateOutputs(bool stop_motors, uint16_t outputs[MAX_ACTUATORS], u @@ -329,8 +329,6 @@ bool TAP_ESC::updateOutputs(bool stop_motors, uint16_t outputs[MAX_ACTUATORS], u
void TAP_ESC::Run()
{
SmartLock lock_guard(_lock);
if (should_exit()) {
ScheduleClear();
_mixing_output.unregister();
@ -339,6 +337,8 @@ void TAP_ESC::Run() @@ -339,6 +337,8 @@ void TAP_ESC::Run()
return;
}
SmartLock lock_guard(_lock);
// push backup schedule
ScheduleDelayed(20_ms);

Loading…
Cancel
Save