[libcamera-devel] [PATCH 3/3] test: v4l2_videodevice: buffer_cache: Fail the test if no buffer from cache is obtained

Laurent Pinchart laurent.pinchart at ideasonboard.com
Tue Apr 14 23:56:56 CEST 2020


Hi Umang,

Thank you for the patch.

On Tue, Apr 14, 2020 at 07:06:59AM +0000, Umang Jain wrote:
> Failing the test guards against negative index (-ENOENT in this case)
> being passed to V4L2BufferCache::put().

Can this happens in practice ?

> Pointed out by Coverity DefectId=279090
> 
> Signed-off-by: Umang Jain <email at uajain.com>
> ---
>  test/v4l2_videodevice/buffer_cache.cpp | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/test/v4l2_videodevice/buffer_cache.cpp b/test/v4l2_videodevice/buffer_cache.cpp
> index d730e75..1870249 100644
> --- a/test/v4l2_videodevice/buffer_cache.cpp
> +++ b/test/v4l2_videodevice/buffer_cache.cpp
> @@ -90,6 +90,11 @@ public:
>  		/* Pick a hot buffer at random and store its index. */
>  		int hotBuffer = dist(generator_);
>  		int hotIndex = cache->get(*buffers[hotBuffer].get());
> +		if (hotIndex < 0) {
> +			std::cout << "Failed lookup from cache" << std::endl;
> +			return TestFail;
> +		}
> +
>  		cache->put(hotIndex);
>  
>  		/*

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list