From a69a8ffb0293e9e962fb7354a94a2872467a2e65 Mon Sep 17 00:00:00 2001 From: Umang Jain Date: Fri, 15 May 2020 12:42:54 +0000 Subject: libcamera: camera: Return -EINVAL if any stream is null while configure() Fail and return the Camera::configure() operation if any of the stream turns out to be a nullptr even after the PipelineHandler handler seems to have configured the config successfully. This prevents a null-dereference below in the loop. Reported-by: Coverity CID=279069 Signed-off-by: Umang Jain Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart Signed-off-by: Kieran Bingham --- src/libcamera/camera.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp index dfc3d193..03f58b4a 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -777,9 +777,12 @@ int Camera::configure(CameraConfiguration *config) p_->activeStreams_.clear(); for (const StreamConfiguration &cfg : *config) { Stream *stream = cfg.stream(); - if (!stream) + if (!stream) { LOG(Camera, Fatal) << "Pipeline handler failed to update stream configuration"; + p_->activeStreams_.clear(); + return -EINVAL; + } stream->configuration_ = cfg; p_->activeStreams_.insert(stream); -- cgit v1.2.1