Re: [PATCH 1/1] media: v4l: Guarantee non-NULL return from v4l2_find_nearest_size()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 15/04/2024 08:04, Sakari Ailus wrote:
> Guarantee that v4l2_find_nearest_size() returns a non-NULL value when the
> mode array passed to it has non-zero number of entries.
> 
> Fixes: 95ce9c28601a ("media: v4l: common: Add a function to obtain best size from a list")
> Signed-off-by: Sakari Ailus <sakari.ailus@xxxxxxxxxxxxxxx>
> ---
>  drivers/media/v4l2-core/v4l2-common.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c
> index d34d210908d9..12e8cbe92d7c 100644
> --- a/drivers/media/v4l2-core/v4l2-common.c
> +++ b/drivers/media/v4l2-core/v4l2-common.c
> @@ -159,7 +159,7 @@ __v4l2_find_nearest_size(const void *array, size_t array_size,
>  			 size_t height_offset, s32 width, s32 height)
>  {
>  	u32 error, min_error = U32_MAX;
> -	const void *best = NULL;
> +	const void *best = array;
>  	unsigned int i;
>  
>  	if (!array)

Has this actually been observed? I don't think it is possible for this
to happen. In fact, I think this actually introduces a new bug: if
array != NULL and array_size == 0, then this would return NULL (correct),
but with this patch it returns 'array' (wrong).

I will drop this patch from the PR until this is clarified.

If this issue was observed, then I can't help thinking that this patch
just addresses the symptom and not the underlying cause.

Regards,

	Hans




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux