[libcamera-devel] [RFC PATCH v1] libcamera: device_enumerator_udev: remove devnum from dependency map

Barnabás Pőcze pobrn at protonmail.com
Sat Apr 15 23:03:40 CEST 2023


Previously, after `addV4L2Device()` had seen all dependecies, it would
remove the `MediaDeviceDeps` object from the `pending_` list, which
would result in it being destroyed. However, there would still be
(dangling) pointers to this object in `devMap_` that were added in
`addUdevDevice()` (line 103). So remove the entry with the given
devnum when it is removed from the corresponding `MediaDeviceDeps`
object.

Signed-off-by: Barnabás Pőcze <pobrn at protonmail.com>
---
 src/libcamera/device_enumerator_udev.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/libcamera/device_enumerator_udev.cpp b/src/libcamera/device_enumerator_udev.cpp
index 5317afbd..a63cd360 100644
--- a/src/libcamera/device_enumerator_udev.cpp
+++ b/src/libcamera/device_enumerator_udev.cpp
@@ -315,6 +315,7 @@ int DeviceEnumeratorUdev::addV4L2Device(dev_t devnum)
 	 * enumerator.
 	 */
 	deps->deps_.erase(devnum);
+	devMap_.erase(it);

 	if (deps->deps_.empty()) {
 		LOG(DeviceEnumerator, Debug)
--
2.40.0




More information about the libcamera-devel mailing list