Re: [PATCH] media: v4l2-ctrls-core.c: check min/max for menu controls

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

 



Le vendredi 02 février 2024 à 11:38 +0100, Hans Verkuil a écrit :
> Menu controls require that the min-max range is inside 0-63.
> 
> Negative values obviously make no sense for menu controls, and the maximum
> value is currently limited by the number of bits of the menu_skip_mask value.
> 
> If we ever need to add support for larger menus, then more work is needed.
> 
> For now just check that everything is within range.
> 
> Signed-off-by: Hans Verkuil <hverkuil-cisco@xxxxxxxxx>

Reviewed-by: Nicolas Dufresne <nicolas.dufresne@xxxxxxxxxxxxx>

> ---
> diff --git a/drivers/media/v4l2-core/v4l2-ctrls-core.c b/drivers/media/v4l2-core/v4l2-ctrls-core.c
> index a662fb60f73f..89d1e3e78563 100644
> --- a/drivers/media/v4l2-core/v4l2-ctrls-core.c
> +++ b/drivers/media/v4l2-core/v4l2-ctrls-core.c
> @@ -1504,7 +1504,8 @@ int check_range(enum v4l2_ctrl_type type,
>  		return 0;
>  	case V4L2_CTRL_TYPE_MENU:
>  	case V4L2_CTRL_TYPE_INTEGER_MENU:
> -		if (min > max || def < min || def > max)
> +		if (min > max || def < min || def > max ||
> +		    min < 0 || max >= BITS_PER_LONG_LONG)
>  			return -ERANGE;
>  		/* Note: step == menu_skip_mask for menu controls.
>  		   So here we check if the default value is masked out. */
> 






[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