media: tda10071: fix unsigned sign extension overflow
authorColin Ian King <colin.king@canonical.com>
Mon, 10 Feb 2020 14:26:46 +0000 (15:26 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 1 Oct 2020 18:40:09 +0000 (20:40 +0200)
commitcf9c9494973292b7c82d4421beb0f0d59131720e
treecdda87ad66e386ad6fcd073887e4b2e6caba8618
parentb7d0ca715c1008acd2fc018f02a56fed88f78b75
media: tda10071: fix unsigned sign extension overflow

[ Upstream commit a7463e2dc698075132de9905b89f495df888bb79 ]

The shifting of buf[3] by 24 bits to the left will be promoted to
a 32 bit signed int and then sign-extended to an unsigned long. In
the unlikely event that the the top bit of buf[3] is set then all
then all the upper bits end up as also being set because of
the sign-extension and this affect the ev->post_bit_error sum.
Fix this by using the temporary u32 variable bit_error to avoid
the sign-extension promotion. This also removes the need to do the
computation twice.

Addresses-Coverity: ("Unintended sign extension")

Fixes: 267897a4708f ("[media] tda10071: implement DVBv5 statistics")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/media/dvb-frontends/tda10071.c