media: cx231xx: fix potential sign-extension overflow on large shift
commitcf205535189770ec61025722a6b426fe28b6bef8
authorColin Ian King <colin.king@canonical.com>
Sat, 6 Oct 2018 18:01:42 +0000 (6 14:01 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 24 Nov 2019 07:23:26 +0000 (24 08:23 +0100)
treee6be25c10fa8506de1661489b983a79fbea6b296
parente30c1d9fc20112cf0b4d7ffaf9a0471d0d0a7f49
media: cx231xx: fix potential sign-extension overflow on large shift

[ Upstream commit 32ae592036d7aeaabcccb2b1715373a68639a768 ]

Shifting the u8 value[3] by an int can lead to sign-extension
overflow. For example, if value[3] is 0xff and the shift is 24 then it
is promoted to int and then the top bit is sign-extended so that all
upper 32 bits are set.  Fix this by casting value[3] to a u32 before
the shift.

Detected by CoverityScan, CID#1016522 ("Unintended sign extension")

Fixes: e0d3bafd0258 ("V4L/DVB (10954): Add cx231xx USB driver")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/media/usb/cx231xx/cx231xx-video.c