]> www.infradead.org Git - users/dwmw2/linux.git/commit
media: ov9650: add a sanity check
authorMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Thu, 22 Aug 2019 14:55:07 +0000 (11:55 -0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 5 Oct 2019 11:13:49 +0000 (13:13 +0200)
commitee3251c9e71f4592abb87e8ca529f045c5530eb2
tree4c91f43a1e6b2380177be575b8cae592a72fbef6
parent826a67380c4a98b6d69774038224c1ce94c51691
media: ov9650: add a sanity check

[ Upstream commit 093347abc7a4e0490e3c962ecbde2dc272a8f708 ]

As pointed by cppcheck:

[drivers/media/i2c/ov9650.c:706]: (error) Shifting by a negative value is undefined behaviour
[drivers/media/i2c/ov9650.c:707]: (error) Shifting by a negative value is undefined behaviour
[drivers/media/i2c/ov9650.c:721]: (error) Shifting by a negative value is undefined behaviour

Prevent mangling with gains with invalid values.

As pointed by Sylvester, this should never happen in practice,
as min value of V4L2_CID_GAIN control is 16 (gain is always >= 16
and m is always >= 0), but it is too hard for a static analyzer
to get this, as the logic with validates control min/max is
elsewhere inside V4L2 core.

Reviewed-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/media/i2c/ov9650.c