From f01cab3be1afc3d601c6b6f39b240b3565d019ff Mon Sep 17 00:00:00 2001 From: David Sidrane Date: Fri, 24 Sep 2021 13:52:27 -0700 Subject: [PATCH] px4io:Ensure proper lifecycle of registration of cdev --- src/drivers/px4io/px4io.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/drivers/px4io/px4io.cpp b/src/drivers/px4io/px4io.cpp index 05dd143433..a50b569d8e 100644 --- a/src/drivers/px4io/px4io.cpp +++ b/src/drivers/px4io/px4io.cpp @@ -510,6 +510,14 @@ PX4IO::~PX4IO() delete _interface; } + /* In the case the task did not exit + * clean up the alternate device node + */ + if (_primary_pwm_device) { + unregister_driver(PWM_OUTPUT0_DEVICE_PATH); + _primary_pwm_device = false; + } + /* deallocate perfs */ perf_free(_perf_update); perf_free(_perf_write); @@ -1217,6 +1225,7 @@ out: /* clean up the alternate device node */ if (_primary_pwm_device) { unregister_driver(PWM_OUTPUT0_DEVICE_PATH); + _primary_pwm_device = false; } /* tell the dtor that we are exiting */