linux/drivers/media
Arnd Bergmann 53dcd70eb7 media: cxd2880-spi: avoid out-of-bounds access warning
The -Warray-bounds warning in gcc-8 triggers for a newly added file:

drivers/media/spi/cxd2880-spi.c: In function 'cxd2880_write_reg':
drivers/media/spi/cxd2880-spi.c:111:3: error: 'memcpy' forming offset [133, 258] is out of the bounds [0, 132] of object 'send_data' with type 'u8[132]' {aka 'unsigned char[132]'} [-Werror=array-bounds]

The problem appears to be that we have two range checks in this function,
first comparing against BURST_WRITE_MAX (128) and then comparing against
a literal '255'. The logic checking the buffer size looks at the second
one and decides that this might be the actual maximum data length.

This is understandable behavior from the compiler, but the code is actually
safe. Since the first check is already shorter, we can remove the loop
and only leave that. To be on the safe side in case BURST_WRITE_MAX might
be increased, I'm leaving the check against U8_MAX.

Fixes: bd24fcddf6 ("media: cxd2880-spi: Add support for CXD2880 SPI interface")

Cc: Martin Sebor <msebor@gmail.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Yasunari Takiguchi <Yasunari.Takiguchi@sony.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-05-04 11:27:00 -04:00
..
cec media: rc: per-protocol repeat period and minimum keyup timer 2018-04-20 09:16:55 -04:00
common media: lgdt330x: convert it to the new I2C binding way 2018-05-04 11:09:26 -04:00
dvb-core media: dvb_frontend: fix locking issues at dvb_frontend_get_event() 2018-04-17 05:49:58 -04:00
dvb-frontends media: lgdt330x: don't use an uninitialized state 2018-05-04 11:17:58 -04:00
firewire vfs: do bulk POLL* -> EPOLL* replacement 2018-02-11 14:34:03 -08:00
i2c media: video-i2c: get rid of two gcc warnings 2018-05-04 10:18:05 -04:00
mmc media: move dvb kAPI headers to include/media 2017-12-28 13:16:01 -05:00
pci media: lgdt330x: convert it to the new I2C binding way 2018-05-04 11:09:26 -04:00
platform media: omap2: allow building it with COMPILE_TEST && DRM_OMAP 2018-05-04 09:55:38 -04:00
radio media: radio: allow building ISA drivers with COMPILE_TEST 2018-05-04 09:08:16 -04:00
rc media: rc: allow build pnp-dependent drivers with COMPILE_TEST 2018-05-04 09:47:45 -04:00
spi media: cxd2880-spi: avoid out-of-bounds access warning 2018-05-04 11:27:00 -04:00
tuners media: r820t: don't crash if attach fails 2018-04-04 05:36:20 -04:00
usb media: lgdt330x: convert it to the new I2C binding way 2018-05-04 11:09:26 -04:00
v4l2-core media: v4l2-core: get rid of videobuf-dvb 2018-05-04 10:57:31 -04:00
Kconfig media updates for v4.17-rc1 2018-04-03 17:16:59 -07:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
media-device.c media: zero reservedX fields in media_v2_topology 2018-02-26 09:47:53 -05:00
media-devnode.c vfs: do bulk POLL* -> EPOLL* replacement 2018-02-11 14:34:03 -08:00
media-entity.c media: media.h: reorganize header to make it easier to understand 2018-02-26 10:14:46 -05:00