media: v4l2-ctrls-core.c: check min/max for menu, controls
authorHans Verkuil <hverkuil-cisco@xs4all.nl>
Mon, 5 Feb 2024 11:10:31 +0000 (12:10 +0100)
committerHans Verkuil <hverkuil-cisco@xs4all.nl>
Fri, 16 Feb 2024 10:46:32 +0000 (11:46 +0100)
commitee0f8674654023320ab61373e2da83e3e0044331
tree0def147c4bb2cebe86b5e4a45e1c9ea1fa4b249d
parent8cda891db3948ef311594270b663bbad2475f790
media: v4l2-ctrls-core.c: check min/max for menu, controls

Menu controls that use the menu_skip_mask 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. However, if menu_skip_mask == 0, then larger menus are fine.

If we ever need to add support for larger menus that support the skip
mask, then more work is needed.

In the places where the menu_skip_mask is checked, use BIT_ULL to get the
bit to check and check if the bit number is < BITS_PER_LONG_LONG to avoid
shifting out of range. With the new check in check_range this should
never happen, but it is better to be safe and avoid static analyzer
warnings.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
drivers/media/v4l2-core/v4l2-ctrls-api.c
drivers/media/v4l2-core/v4l2-ctrls-core.c