From dcb90f13cf79d909d04dacf2cfbd256a4744347f Mon Sep 17 00:00:00 2001 From: Kieran Bingham Date: Fri, 8 Nov 2024 23:34:15 +0000 Subject: CameraManager: Ensure we cleanup on failure If the CameraManager fails to initialise at startup during CameraManager::Private::init(), then the run() function will prepare the thread for operations, but the thread will immediately close without executing any cleanup. This can leave instantiated objects such as the EventNotifier registered by the udev enumerator constructed in a thread which no longer exists. The destructor of those objects can then fire an assertion that they are being executed from an incorrect thread while performing their cleanup. Ensure that the failure path does not result in reporting thread ownership assertions by performing cleanup correctly on the CameraManager thread before it closes. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Signed-off-by: Kieran Bingham --- src/libcamera/camera_manager.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp index 09f58776..c7cc5adb 100644 --- a/src/libcamera/camera_manager.cpp +++ b/src/libcamera/camera_manager.cpp @@ -80,8 +80,10 @@ void CameraManager::Private::run() mutex_.unlock(); cv_.notify_one(); - if (ret < 0) + if (ret < 0) { + cleanup(); return; + } /* Now start processing events and messages. */ exec(); -- cgit v1.2.1