diff --git a/platforms/common/uORB/uORBDeviceNode.cpp b/platforms/common/uORB/uORBDeviceNode.cpp index cfb92a21c3b4..c4c765cde90a 100644 --- a/platforms/common/uORB/uORBDeviceNode.cpp +++ b/platforms/common/uORB/uORBDeviceNode.cpp @@ -917,6 +917,12 @@ uORB::DeviceNode::_unregister_callback(uorb_cb_handle_t &cb_handle) PX4_ERR("unregister fail\n"); } else { + EventWaitItem *item = callbacks.peek(cb_handle); + + while (__atomic_fetch_sub(&item->cb_triggered, 1, __ATOMIC_SEQ_CST) >= 0) { + Manager::lockThread(item->lock); + } + callbacks.push_free(cb_handle); cb_handle = UORB_INVALID_CB_HANDLE; }