[libcamera-devel] [PATCH 7/8] libcamera: camera: ensure streams belong to camera

Jacopo Mondi jacopo at jmondi.org
Tue Feb 26 18:20:16 CET 2019


Hi Niklas,
   great! If this needs to be checked in other places, you could
   consider a method for this in future.

Reviewed-by: Jacopo Mondi <jacopo at jmondi.org>

Thanks
  j

On Tue, Feb 26, 2019 at 03:18:56AM +0100, Niklas Söderlund wrote:
> Before calling into the pipeline handler make sure the streams provided
> by the application actually belongs to the camera.
>
> Signed-off-by: Niklas Söderlund <niklas.soderlund at ragnatech.se>
> ---
>  src/libcamera/camera.cpp | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp
> index 938f21fe80ef8ceb..ba8638009992170f 100644
> --- a/src/libcamera/camera.cpp
> +++ b/src/libcamera/camera.cpp
> @@ -253,6 +253,10 @@ Camera::streamConfiguration(std::set<Stream *> &streams)
>  	if (!stateIsAtleast(Free) || !streams.size())
>  		return std::map<Stream *, StreamConfiguration>{};
>
> +	for (Stream *stream : streams)
> +		if (streams_.find(stream) == streams_.end())
> +			return std::map<Stream *, StreamConfiguration>{};
> +
>  	return pipe_->streamConfiguration(this, streams);
>  }
>
> @@ -290,6 +294,10 @@ int Camera::configureStreams(std::map<Stream *, StreamConfiguration> &config)
>  		return -EINVAL;
>  	}
>
> +	for (auto const &iter : config)
> +		if (streams_.find(iter.first) == streams_.end())
> +			return -EINVAL;
> +
>  	ret = pipe_->configureStreams(this, config);
>  	if (ret)
>  		return ret;
> --
> 2.20.1
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel at lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.libcamera.org/pipermail/libcamera-devel/attachments/20190226/0ef7bfa8/attachment.sig>


More information about the libcamera-devel mailing list