linux-uconsole/drivers/media/platform
Arnd Bergmann c9e62716c6 media: s3c-camif: fix out-of-bounds array access
[ Upstream commit a398e04363 ]

While experimenting with older compiler versions, I ran
into a warning that no longer shows up on gcc-4.8 or newer:

drivers/media/platform/s3c-camif/camif-capture.c: In function '__camif_subdev_try_format':
drivers/media/platform/s3c-camif/camif-capture.c:1265:25: error: array subscript is below array bounds

This is an off-by-one bug, leading to an access before the start of the
array, while newer compilers silently assume this undefined behavior
cannot happen and leave the loop at index 0 if no other entry matches.

As Sylvester explains, we actually need to ensure that the
value is within the range, so this reworks the loop to be
easier to parse correctly, and an additional check to fall
back on the first format value for any unexpected input.

I found an existing gcc bug for it and added a reduced version
of the function there.

Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69249#c3
Fixes: babde1c243 ("[media] V4L: Add driver for S3C24XX/S3C64XX SoC series camera interface")

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-30 07:49:14 +02:00
..
am437x am437x-vpfe: always assign bpp variable 2017-03-12 06:37:24 +01:00
blackfin blackfin: check devm_pinctrl_get() for errors 2017-01-26 08:23:49 +01:00
coda coda: fix error path in case of missing pdata on non-DT platform 2016-04-20 15:42:09 +09:00
davinci media: platform: davinci: return -EINVAL for VPFE_CMD_S_CCDC_RAW_PARAMS ioctl 2017-08-11 09:08:48 -07:00
exynos-gsc exynos-gsc: Do not swap cb/cr for semi planar formats 2017-10-08 10:14:19 +02:00
exynos4-is exynos4-is: fimc-is: Unmap region obtained by of_iomap() 2017-11-08 10:06:30 +01:00
marvell-ccic [media] media: videobuf2: Change queue_setup argument 2015-10-20 14:48:39 -02:00
omap media updates for v4.3-rc1 2015-09-11 16:42:39 -07:00
omap3isp [media] media: videobuf2: Change queue_setup argument 2015-10-20 14:48:39 -02:00
s3c-camif media: s3c-camif: fix out-of-bounds array access 2018-05-30 07:49:14 +02:00
s5p-g2d [media] media: videobuf2: Change queue_setup argument 2015-10-20 14:48:39 -02:00
s5p-jpeg s5p-jpeg: don't return a random width/height 2017-07-27 15:06:02 -07:00
s5p-mfc s5p-mfc: Fix unbalanced call to clock management 2017-05-25 14:30:14 +02:00
s5p-tv [media] media: videobuf2: Change queue_setup argument 2015-10-20 14:48:39 -02:00
soc_camera media: soc_camera: soc_scale_crop: add missing MODULE_DESCRIPTION/AUTHOR/LICENSE 2018-02-16 20:09:38 +01:00
sti media: c8sectpfe: fix potential NULL pointer dereference in c8sectpfe_timer_interrupt 2018-03-24 10:58:46 +01:00
ti-vpe [media] media: videobuf2: Change queue_setup argument 2015-10-20 14:48:39 -02:00
vivid [media] media/vivid-osd: fix info leak in ioctl 2015-10-20 15:34:29 -02:00
vsp1 v4l: vsp1: Set the SRU CTRL0 register when starting the stream 2016-04-20 15:42:09 +09:00
xilinx [media] media: videobuf2: Change queue_setup argument 2015-10-20 14:48:39 -02:00
arv.c
fsl-viu.c [media] fsl-viu: drop format names 2015-08-11 06:59:09 -03:00
Kconfig [media] VIDEO_RENESAS_JPU should depend on HAS_DMA 2015-10-03 10:01:48 -03:00
m2m-deinterlace.c [media] media: videobuf2: Change queue_setup argument 2015-10-20 14:48:39 -02:00
Makefile [media] c8sectpfe: Add Kconfig and Makefile for the driver 2015-08-11 16:08:29 -03:00
mx2_emmaprp.c [media] media: videobuf2: Change queue_setup argument 2015-10-20 14:48:39 -02:00
rcar_jpu.c [media] media: videobuf2: Change queue_setup argument 2015-10-20 14:48:39 -02:00
sh_veu.c [media] media: videobuf2: Change queue_setup argument 2015-10-20 14:48:39 -02:00
sh_vou.c [media] media: videobuf2: Change queue_setup argument 2015-10-20 14:48:39 -02:00
timblogiw.c
via-camera.c [media] v4l2: replace s_mbus_fmt by set_fmt in bridge drivers 2015-05-01 09:01:16 -03:00
via-camera.h
vim2m.c [media] media: videobuf2: Change queue_setup argument 2015-10-20 14:48:39 -02:00