libcamera: pipeline: Fix double release of media devices

Media devices are acquired in the match() function of pipeline handlers,
and explicitly released if no match is found. The pipeline handler is
then deleted, which causes a second release of the media device in the
destructor. Fix this by removing the explicit release in the match()
function.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Acked-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
Laurent Pinchart 2019-02-28 12:39:46 +02:00
parent 3ab7f65d6f
commit e6eff721d7
3 changed files with 12 additions and 22 deletions

View file

@ -278,19 +278,20 @@ bool PipelineHandlerIPU3::match(DeviceEnumerator *enumerator)
imgu_dm.add("ipu3-imgu 1 viewfinder"); imgu_dm.add("ipu3-imgu 1 viewfinder");
imgu_dm.add("ipu3-imgu 1 3a stat"); imgu_dm.add("ipu3-imgu 1 3a stat");
/*
* It is safe to acquire both media devices at this point as
* DeviceEnumerator::search() skips the busy ones for us.
*/
cio2_ = enumerator->search(cio2_dm); cio2_ = enumerator->search(cio2_dm);
if (!cio2_) if (!cio2_)
return false; return false;
cio2_->acquire();
imgu_ = enumerator->search(imgu_dm); imgu_ = enumerator->search(imgu_dm);
if (!imgu_) if (!imgu_)
return false; return false;
/*
* It is safe to acquire both media devices at this point as
* DeviceEnumerator::search() skips the busy ones for us.
*/
cio2_->acquire();
imgu_->acquire(); imgu_->acquire();
/* /*
@ -301,25 +302,18 @@ bool PipelineHandlerIPU3::match(DeviceEnumerator *enumerator)
* not need to be changed after. * not need to be changed after.
*/ */
if (cio2_->open()) if (cio2_->open())
goto error_release_mdev; return false;
if (cio2_->disableLinks()) if (cio2_->disableLinks()) {
goto error_close_cio2; cio2_->close();
return false;
}
registerCameras(); registerCameras();
cio2_->close(); cio2_->close();
return true; return true;
error_close_cio2:
cio2_->close();
error_release_mdev:
cio2_->release();
imgu_->release();
return false;
} }
/* /*

View file

@ -167,7 +167,6 @@ bool PipelineHandlerUVC::match(DeviceEnumerator *enumerator)
if (!video_) if (!video_)
LOG(UVC, Error) << "Could not find a default video device"; LOG(UVC, Error) << "Could not find a default video device";
media_->release();
return false; return false;
} }

View file

@ -165,11 +165,8 @@ bool PipelineHandlerVimc::match(DeviceEnumerator *enumerator)
media_->acquire(); media_->acquire();
video_ = new V4L2Device(media_->getEntityByName("Raw Capture 1")); video_ = new V4L2Device(media_->getEntityByName("Raw Capture 1"));
if (video_->open())
if (video_->open()) {
media_->release();
return false; return false;
}
std::set<Stream *> streams{ &stream_ }; std::set<Stream *> streams{ &stream_ };
std::shared_ptr<Camera> camera = Camera::create(this, "VIMC Sensor B", std::shared_ptr<Camera> camera = Camera::create(this, "VIMC Sensor B",