linux/drivers/media/usb/dvb-usb-v2
Mauro Carvalho Chehab 845b978a87 media: rtl28xxu: be sure that it won't go past the array size
smatch warns that the RC query code could go past the array size:

	drivers/media/usb/dvb-usb-v2/rtl28xxu.c:1757 rtl2832u_rc_query() error: buffer overflow 'buf' 128 <= 130
	drivers/media/usb/dvb-usb-v2/rtl28xxu.c:1758 rtl2832u_rc_query() error: buffer overflow 'buf' 128 <= 130

The driver logic gets the length of the IR RX buffer with:

        ret = rtl28xxu_rd_reg(d, IR_RX_BC, &buf[0]);
	...
        len = buf[0];

In thesis, this could range between 0 and 255 [1].

While this should never happen in practice, due to hardware limits,
smatch is right when it complains about that, as there's nothing at
the logic that would prevent it. So, if for whatever reason, buf[0]
gets filled by rtl28xx read functions with a value bigger than 128,
it will go past the array.

So, add an explicit check.

[1] I've no idea why smatch thinks that the maximum value is 130.
I double-checked the code several times. Was unable to find any
reason for assuming 130. Perhaps smatch is not properly parsing
u8 here?

Fixes: b5cbaa43a6 ("[media] rtl28xx: initial support for rtl2832u")
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-08-08 10:57:14 -04:00
..
Kconfig media: dvb-usb/friio, dvb-usb-v2/gl861: decompose friio and merge with gl861 2018-07-30 08:50:25 -04:00
Makefile media: move dvb kAPI headers to include/media 2017-12-28 13:16:01 -05:00
af9015.c media: af9015: correct some coding style issues 2018-03-21 14:16:32 -04:00
af9015.h media: af9015: convert to regmap api 2018-03-21 14:15:34 -04:00
af9035.c media: rc: rename RC_TYPE_* to RC_PROTO_* and RC_BIT_* to RC_PROTO_BIT_* 2017-08-20 10:02:48 -04:00
af9035.h [media] af9035: register it9133 tuner using platform binding 2017-01-31 10:49:42 -02:00
anysee.c media: rc: rename RC_TYPE_* to RC_PROTO_* and RC_BIT_* to RC_PROTO_BIT_* 2017-08-20 10:02:48 -04:00
anysee.h media: move dvb kAPI headers to include/media 2017-12-28 13:16:01 -05:00
au6610.c [media] media: Drop FSF's postal address from the source code files 2017-01-27 11:38:09 -02:00
au6610.h [media] media: Drop FSF's postal address from the source code files 2017-01-27 11:38:09 -02:00
az6007.c media: move dvb kAPI headers to include/media 2017-12-28 13:16:01 -05:00
ce6230.c [media] media: Drop FSF's postal address from the source code files 2017-01-27 11:38:09 -02:00
ce6230.h [media] media: Drop FSF's postal address from the source code files 2017-01-27 11:38:09 -02:00
dvb_usb.h media: dvb-usb-v2: add probe/disconnect callbacks 2018-03-21 14:15:09 -04:00
dvb_usb_common.h [media] media: change email address 2016-01-25 12:01:08 -02:00
dvb_usb_core.c media: dvb: fix location of get_dvb_firmware script 2018-06-15 18:10:01 -03:00
dvb_usb_urb.c [media] media: change email address 2016-01-25 12:01:08 -02:00
dvbsky.c media: dvbsky: use just one mutex for serializing device R/W ops 2018-05-10 07:05:14 -04:00
ec168.c [media] media: Drop FSF's postal address from the source code files 2017-01-27 11:38:09 -02:00
ec168.h [media] media: Drop FSF's postal address from the source code files 2017-01-27 11:38:09 -02:00
gl861.c media: dvb-usb/friio, dvb-usb-v2/gl861: decompose friio and merge with gl861 2018-07-30 08:50:25 -04:00
gl861.h media: dvb-usb/friio, dvb-usb-v2/gl861: decompose friio and merge with gl861 2018-07-30 08:50:25 -04:00
lmedm04.c media: dvb: point to the location of the old README.dvb-usb file 2018-06-15 18:10:01 -03:00
lmedm04.h media: dvb: point to the location of the old README.dvb-usb file 2018-06-15 18:10:01 -03:00
mxl111sf-demod.c media: dvb: represent min/max/step/tolerance freqs in Hz 2018-08-02 18:10:48 -04:00
mxl111sf-demod.h media: move dvb kAPI headers to include/media 2017-12-28 13:16:01 -05:00
mxl111sf-gpio.c [media] media: Drop FSF's postal address from the source code files 2017-01-27 11:38:09 -02:00
mxl111sf-gpio.h [media] media: Drop FSF's postal address from the source code files 2017-01-27 11:38:09 -02:00
mxl111sf-i2c.c media: mxl111sf: remove redundant assignment to index 2017-10-31 07:27:14 -04:00
mxl111sf-i2c.h [media] media: Drop FSF's postal address from the source code files 2017-01-27 11:38:09 -02:00
mxl111sf-phy.c [media] media: Drop FSF's postal address from the source code files 2017-01-27 11:38:09 -02:00
mxl111sf-phy.h [media] media: Drop FSF's postal address from the source code files 2017-01-27 11:38:09 -02:00
mxl111sf-reg.h [media] media: Drop FSF's postal address from the source code files 2017-01-27 11:38:09 -02:00
mxl111sf-tuner.c media: dvb: convert tuner_info frequencies to Hz 2018-08-02 16:14:50 -04:00
mxl111sf-tuner.h media: move dvb kAPI headers to include/media 2017-12-28 13:16:01 -05:00
mxl111sf.c media: dvb: point to the location of the old README.dvb-usb file 2018-06-15 18:10:01 -03:00
mxl111sf.h media: dvb: point to the location of the old README.dvb-usb file 2018-06-15 18:10:01 -03:00
rtl28xxu.c media: rtl28xxu: be sure that it won't go past the array size 2018-08-08 10:57:14 -04:00
rtl28xxu.h [media] rtl28xxu: fix control message flaws 2015-10-22 15:48:27 -02:00
usb_urb.c media: dvb-usb-v2: fix spelling mistake: "completition" -> "completion" 2018-08-03 16:09:22 -04:00
zd1301.c [media] zd1301: fix building interface driver without demodulator 2017-02-08 11:59:39 -02:00