From 6225d647b47982833fa654bf9cf65eb8c04d2036 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sat, 3 Sep 2022 17:44:00 +0300 Subject: pipeline: uvcvideo: Fail match() if the camera has no supported format A UVC device could expose only formats that are not supported by libcamera. The pipeline handler doesn't currently consider this as an error, and happily creates a camera. The camera won't be usable, and worse, generateConfiguration() and validate() will crash as those functions assume that at least one format is supported. Fix this by failing match() if none of the formats exposed by the camera are supported. Log an error message in that case to notify the user. Bug: https://bugs.libcamera.org/show_bug.cgi?id=145 Signed-off-by: Laurent Pinchart Reviewed-by: Umang Jain Reviewed-by: Kieran Bingham Tested-by: Christian Rauch --- src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/libcamera') diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp index be0fbaea..a2819545 100644 --- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp @@ -457,6 +457,13 @@ int UVCCameraData::init(MediaDevice *media) } } + if (formats_.empty()) { + LOG(UVC, Error) + << "Camera " << id_ << " (" << media->model() + << ") doesn't expose any supported format"; + return -EINVAL; + } + /* Populate the camera properties. */ properties_.set(properties::Model, utils::toAscii(media->model())); -- cgit v1.2.1