OSDN Git Service

media: TDA1997x: handle short reads of hdmi info frame.
authorTom Rix <trix@redhat.com>
Thu, 12 Aug 2021 17:00:43 +0000 (19:00 +0200)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Thu, 30 Sep 2021 08:07:54 +0000 (10:07 +0200)
commit48d219f9cc667bc6fbc3e3af0b1bfd75db94fce4
tree212d348c22a46b6cfc13d164ddaa81f1e4452052
parentcdfaf4752e6915a4b455ad4400133e540e4dc965
media: TDA1997x: handle short reads of hdmi info frame.

Static analysis reports this representative problem

tda1997x.c:1939: warning: 7th function call argument is an uninitialized
value

The 7th argument is buffer[0], which is set in the earlier call to
io_readn().  When io_readn() call to io_read() fails with the first
read, buffer[0] is not set and 0 is returned and stored in len.

The later call to hdmi_infoframe_unpack()'s size parameter is the
static size of buffer, always 40, so a short read is not caught
in hdmi_infoframe_unpacks()'s checking.  The variable len should be
used instead.

Zero initialize buffer to 0 so it is in a known start state.

Fixes: 9ac0038db9a7 ("media: i2c: Add TDA1997x HDMI receiver driver")
Signed-off-by: Tom Rix <trix@redhat.com>
Reviewed-by: Tim Harvey <tharvey@gateworks.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/i2c/tda1997x.c