media: v4l: ioctl: Sanitize num_planes before using it
authorEzequiel Garcia <ezequiel@collabora.com>
Mon, 18 Feb 2019 10:25:42 +0000 (05:25 -0500)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Mon, 18 Feb 2019 15:13:38 +0000 (10:13 -0500)
commit14c8e80e68695c2b9342112c39263a79e0963461
treeee1fac4cbfa037a96b75d7513e1b8c6b34544b34
parent5f09bc8cc4010a3ea17c5881a62fc45192ebe7b0
media: v4l: ioctl: Sanitize num_planes before using it

The linked commit changed s_fmt/try_fmt to fail if num_planes is bogus.
This, however, is against the spec, which mandates drivers
to return a proper num_planes value, without an error.

Replace the num_planes check and instead clamp it to a sane value,
so we still make sure we don't overflow the planes array by accident.

Fixes: 9048b2e15b11c5 ("media: v4l: ioctl: Validate num_planes before using it")

Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
drivers/media/v4l2-core/v4l2-ioctl.c