libcamera: device_enumerator_udev: Remove devnum from dependency map

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@protonmail.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Barnabás Pőcze 2023-04-15 21:03:40 +00:00 committed by Laurent Pinchart
parent 98fc381c68
commit f99b0f7f8f

View file

@ -315,6 +315,7 @@ int DeviceEnumeratorUdev::addV4L2Device(dev_t devnum)
* enumerator. * enumerator.
*/ */
deps->deps_.erase(devnum); deps->deps_.erase(devnum);
devMap_.erase(it);
if (deps->deps_.empty()) { if (deps->deps_.empty()) {
LOG(DeviceEnumerator, Debug) LOG(DeviceEnumerator, Debug)