]> git.baikalelectronics.ru Git - kernel.git/commit
media: cx231xx: fix potential sign-extension overflow on large shift
authorColin Ian King <colin.king@canonical.com>
Sat, 6 Oct 2018 18:01:42 +0000 (14:01 -0400)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Tue, 9 Oct 2018 12:05:48 +0000 (08:05 -0400)
commit472269ee2d997612fca82f2568c07118731e59af
tree70b554b39b6513d6324e2301cdb910e244ecda25
parent0253102adb045dcc0ec7cf046b61271ae0addd36
media: cx231xx: fix potential sign-extension overflow on large shift

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: b59cb6a597b9 ("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>
drivers/media/usb/cx231xx/cx231xx-video.c