From patchwork Tue Sep 29 10:59:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 291175 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DFD90C4727C for ; Tue, 29 Sep 2020 11:16:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9A2BD21D41 for ; Tue, 29 Sep 2020 11:16:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601378172; bh=JFcziiMZPj20xMvToNrRfM7rOBWitPffkIwwunEFBcw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Kv6lskwuQzPqThz8ROSE7ASqcPQVxQZK6Xk5Fr3c1CdxXiHnp8SIwLmaKPe1Sbx3N i2eKky3NXapnGSS7YewcY4eJ9KNbyQLiGdx9L8crSr7d+bV2mIsJlUKwpzCRY+cRjX VUksCNLWPmPzVUPkZPe3f0PqT6uT3zoGOvKSh9lI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729184AbgI2LQL (ORCPT ); Tue, 29 Sep 2020 07:16:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:60564 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728454AbgI2LP6 (ORCPT ); Tue, 29 Sep 2020 07:15:58 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1198C208FE; Tue, 29 Sep 2020 11:15:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601378157; bh=JFcziiMZPj20xMvToNrRfM7rOBWitPffkIwwunEFBcw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o+IdsrqF+ddJ1PzKf8elXUwVQXUblB2nL5GwqjgnJBa9vPiUAuEZQuOuJbtSV+zVS 5MSTL9lYOctRNad+BBvL+k8qrQRFwtAFyM5Sg8kRJWWI/0/weQB2FfR3FKg0hQ6c0j cX6lb2z/ZHVEsZ+0zC793jg7KrUODQgbGWmTGqbU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Colin Ian King , Sean Young , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 4.14 081/166] media: tda10071: fix unsigned sign extension overflow Date: Tue, 29 Sep 2020 12:59:53 +0200 Message-Id: <20200929105939.259372247@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200929105935.184737111@linuxfoundation.org> References: <20200929105935.184737111@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Colin Ian King [ 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 Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/dvb-frontends/tda10071.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/media/dvb-frontends/tda10071.c b/drivers/media/dvb-frontends/tda10071.c index a59f4fd09df60..27466b0d0be86 100644 --- a/drivers/media/dvb-frontends/tda10071.c +++ b/drivers/media/dvb-frontends/tda10071.c @@ -483,10 +483,11 @@ static int tda10071_read_status(struct dvb_frontend *fe, enum fe_status *status) goto error; if (dev->delivery_system == SYS_DVBS) { - dev->dvbv3_ber = buf[0] << 24 | buf[1] << 16 | - buf[2] << 8 | buf[3] << 0; - dev->post_bit_error += buf[0] << 24 | buf[1] << 16 | - buf[2] << 8 | buf[3] << 0; + u32 bit_error = buf[0] << 24 | buf[1] << 16 | + buf[2] << 8 | buf[3] << 0; + + dev->dvbv3_ber = bit_error; + dev->post_bit_error += bit_error; c->post_bit_error.stat[0].scale = FE_SCALE_COUNTER; c->post_bit_error.stat[0].uvalue = dev->post_bit_error; dev->block_error += buf[4] << 8 | buf[5] << 0;