[libcamera-devel,v4,2/2] android: CameraDevice: Validate buffer_handle by CameraBuffer::isValidBuffer()
diff mbox series

Message ID 20210416134347.2881373-2-hiroh@chromium.org
State Rejected
Headers show
Series
  • [libcamera-devel,v4,1/2] android: CameraBuffer: Add a static function to check a buffer validness
Related show

Commit Message

Hirokazu Honda April 16, 2021, 1:43 p.m. UTC
This adds a validation to buffer_handle provided in
CameraDevice::processCaptureRequest() by using
CameraBuffer::isValidBuffer().

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
---
 src/android/camera_device.cpp | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Laurent Pinchart April 16, 2021, 3:41 p.m. UTC | #1
Hi Hiro,

Thank you for the patch.

On Fri, Apr 16, 2021 at 10:43:47PM +0900, Hirokazu Honda wrote:
> This adds a validation to buffer_handle provided in
> CameraDevice::processCaptureRequest() by using
> CameraBuffer::isValidBuffer().
> 
> Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>

I think you can squash this with the previous patch.

I wonder, however, what errors you expect this to catch. When can we
receive an invalid buffer handle from the camera service ?

> ---
>  src/android/camera_device.cpp | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> index 89044efa..7247c12c 100644
> --- a/src/android/camera_device.cpp
> +++ b/src/android/camera_device.cpp
> @@ -293,6 +293,11 @@ bool isValidRequest(camera3_capture_request_t *camera3Request)
>  				<< ") in buffer " << i;
>  			return false;
>  		}
> +
> +		if (!CameraBuffer::isValidBuffer(handle)) {
> +			LOG(HAL, Error) << "Buffer " << i << " is invalid";
> +			return false;
> +		}
>  	}
>  
>  	return true;

Patch
diff mbox series

diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index 89044efa..7247c12c 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -293,6 +293,11 @@  bool isValidRequest(camera3_capture_request_t *camera3Request)
 				<< ") in buffer " << i;
 			return false;
 		}
+
+		if (!CameraBuffer::isValidBuffer(handle)) {
+			LOG(HAL, Error) << "Buffer " << i << " is invalid";
+			return false;
+		}
 	}
 
 	return true;