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

Jacopo Mondi jacopo.mondi at ideasonboard.com
Mon Apr 17 08:30:33 CEST 2023


Hi Barnabás

On Sat, Apr 15, 2023 at 09:03:40PM +0000, Barnabás Pőcze via libcamera-devel wrote:
> 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);

Shouldn't this be done only when all the dependencies are actually
satisfied ?

>
>  	if (deps->deps_.empty()) {

Likely inside this if() clause ?

Otherwise, if there still are dependencies to meet for the devnum at
hand, the next time addV4L2Device(devnum) is called it won't find any item
on the devMap_ for that key.

>  		LOG(DeviceEnumerator, Debug)
> --
> 2.40.0
>
>


More information about the libcamera-devel mailing list