media: v4l2-ctrls: Fix off-by-one error in integer menu control check
authorLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Mon, 26 Sep 2022 16:31:51 +0000 (19:31 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 31 Dec 2022 12:32:03 +0000 (13:32 +0100)
commitb9d1093140e2cee2a196f2925cd76e871c119cd3
tree0f661ff66ae4f5afc0498d735532fa6fb0d2e77f
parenta7e8439e297ef3b08b1a9455b8c355b7fa446987
media: v4l2-ctrls: Fix off-by-one error in integer menu control check

[ Upstream commit b6bcdf763db1f5ea602bf876cfe91debfb3c7773 ]

The V4L2 API defines the maximum value for an integer menu control as
the number of elements minus one. The v4l2_ctrl_new_std_menu() validates
this constraint with an off-by-one error. Fix it.

Fixes: d1e9b7c12b74 ("[media] V4L: Add support for integer menu controls with standard menu items")
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/media/v4l2-core/v4l2-ctrls-core.c