[libcamera-devel] [PATCH v2 4/4] libcamera: camera: Return -EINVAL if any stream is null while configure()
Umang Jain
email at uajain.com
Fri May 15 14:42:54 CEST 2020
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.
Pointed out by Coverity DefectId=279069
Signed-off-by: Umang Jain <email at uajain.com>
---
src/libcamera/camera.cpp | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp
index 8c3bb2c..9d2607b 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);
--
2.26.2
More information about the libcamera-devel
mailing list