[libcamera-devel] [PATCH] libcamera: Release all devices on shutdown
Kieran Bingham
kieran.bingham at ideasonboard.com
Sat Oct 8 15:12:17 CEST 2022
Quoting Umang Jain via libcamera-devel (2022-10-08 18:34:43)
> Hi Christian
>
> On 10/8/22 4:45 PM, Christian Rauch via libcamera-devel wrote:
> > Some devices may not be released via their 'PipelineHandler'. This results
>
> Can you explain better which are those devices / platform for which
> PipelineHandler does not release the devices? Do you have any particular
> case in mind?
>
> It's the job of the pipeline handler to correctly release the device,
> since it's the one acquired it in the first place.
> > in these devices still being acquired or busy on shutdown. Make sure that
> > all devices are released when DeviceEnumerator is deconstructed.
> >
> > Signed-off-by: Christian Rauch <Rauch.Christian at gmx.de>
> > ---
> > src/libcamera/device_enumerator.cpp | 8 ++------
> > 1 file changed, 2 insertions(+), 6 deletions(-)
> >
> > diff --git a/src/libcamera/device_enumerator.cpp b/src/libcamera/device_enumerator.cpp
> > index f2e055de..d0968a0a 100644
> > --- a/src/libcamera/device_enumerator.cpp
> > +++ b/src/libcamera/device_enumerator.cpp
> > @@ -161,12 +161,8 @@ std::unique_ptr<DeviceEnumerator> DeviceEnumerator::create()
> >
> > DeviceEnumerator::~DeviceEnumerator()
> > {
> > - for (const std::shared_ptr<MediaDevice> &media : devices_) {
> > - if (media->busy())
> > - LOG(DeviceEnumerator, Error)
> > - << "Removing media device " << media->deviceNode()
> > - << " while still in use";
> > - }
> > + for (const std::shared_ptr<MediaDevice> &media : devices_)
> > + media->release();
>
> I believe this shadows a bug and forcibly releases a device here, which
> should ideally be released by the pipeline handler in the first place.
> The Error log is present there to catch such instances I think!
This is my worry too. I wonder if we can record who/where the media
device is opened, and report that here?
If this releases the media device, does that leave the pipeline handler
still accessing it? (thus leading on to a new bug / use after free)
--
Kieran
> > }
> >
> > /**
> > --
> > 2.34.1
> >
>
More information about the libcamera-devel
mailing list