summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorUmang Jain <email@uajain.com>2020-05-15 12:42:54 +0000
committerKieran Bingham <kieran.bingham@ideasonboard.com>2020-06-04 11:02:39 +0100
commita69a8ffb0293e9e962fb7354a94a2872467a2e65 (patch)
tree9050f8c50a57219a9c275e3ade859cd9d00fe16b /src
parent3706b716eba66e77c27ab365f54e6b13f145fea8 (diff)
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 <email@uajain.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src')
-rw-r--r--src/libcamera/camera.cpp5
1 files changed, 4 insertions, 1 deletions
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);