[libcamera-devel] [PATCH 2/2] android: Check if Stream configurations were generated correctly
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Tue Oct 12 04:39:58 CEST 2021
Hi Javier,
Thank you for the patch.
On Fri, Oct 01, 2021 at 06:11:00PM +0200, Javier Martinez Canillas wrote:
> The libcamera Android Camera HAL generates camera configurations for the
> StillCapture, Raw and ViewFinder stream roles. But it's only checked for
> the first one if the function succeeded.
>
> This could lead to a NULL pointer deference if a pipeline handler failed
s/deference/dereference/
I'll fix this when applying.
> to generate a default configuration for one the other two stream roles.
>
> Signed-off-by: Javier Martinez Canillas <javierm at redhat.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> ---
>
> src/android/camera_capabilities.cpp | 13 ++++++++++++-
> 1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp
> index 87a6e1c6f26..baeedc11500 100644
> --- a/src/android/camera_capabilities.cpp
> +++ b/src/android/camera_capabilities.cpp
> @@ -408,6 +408,11 @@ CameraCapabilities::initializeYUVResolutions(const PixelFormat &pixelFormat,
> std::vector<Size> supportedResolutions;
> std::unique_ptr<CameraConfiguration> cameraConfig =
> camera_->generateConfiguration({ StreamRole::Viewfinder });
> + if (!cameraConfig) {
> + LOG(HAL, Error) << "Failed to get supported YUV resolutions";
> + return supportedResolutions;
> + }
> +
> StreamConfiguration &cfg = cameraConfig->at(0);
>
> for (const Size &res : resolutions) {
> @@ -431,11 +436,17 @@ CameraCapabilities::initializeYUVResolutions(const PixelFormat &pixelFormat,
> std::vector<Size>
> CameraCapabilities::initializeRawResolutions(const PixelFormat &pixelFormat)
> {
> + std::vector<Size> supportedResolutions;
> std::unique_ptr<CameraConfiguration> cameraConfig =
> camera_->generateConfiguration({ StreamRole::Raw });
> + if (!cameraConfig) {
> + LOG(HAL, Error) << "Failed to get supported Raw resolutions";
> + return supportedResolutions;
> + }
> +
> StreamConfiguration &cfg = cameraConfig->at(0);
> const StreamFormats &formats = cfg.formats();
> - std::vector<Size> supportedResolutions = formats.sizes(pixelFormat);
> + supportedResolutions = formats.sizes(pixelFormat);
>
> return supportedResolutions;
> }
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list