Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp878489pxk; Thu, 17 Sep 2020 20:07:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw40QZKmqw/CEWrRSXh52XzfSdz43Y1Bq0VYqEOHj8rBX0iczl29owyScwfpkYo4UQYJtOI X-Received: by 2002:aa7:d8d8:: with SMTP id k24mr35626768eds.97.1600398448548; Thu, 17 Sep 2020 20:07:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600398448; cv=none; d=google.com; s=arc-20160816; b=mosFJLbZ1hYjIfhbUzDhhHs28ZFUjY2z+ebGpxeEI8vgoBV387pcJVM0OgJ2Sp3524 282AU51Kqf4suLbGhMw7GDe5gK/QwOc5DD7W9SeJfCvDVnmMLi8WnDVCfxNXsc0oElWV JrFX4DNRRHBTER4Dx59TPiF6GTq/3MY/pihDB7/0q6GCCLBm90tWIP/ML9q4kRby7Ug9 Irc0pCCXRleQt2lTRS/uZqTs4WdE4Y1ryThTDKCPfRFonnd2uahn9t7ND0uC5wJmxjCA fOrc0Js+3julobBSgnCIGQJjyATcOYpq3cm5QB5VtxT/Z/Znh9x732B/zIU45E/n54e+ 1tHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=b6U+REkvL/yw2dzX53lnydZ0/abZ9BuZgEE4G16vjZI=; b=hXLbt9DJ2V2NHrNbHMo3FiBL1cw8vevYtxupCWr5rS0rT94HZ7Mr0MnnApyUuIaqvp 0/pDuGvyBQqkXwWQdEklzp3Q5UKPLa5weBcth8AL1PSgmiQHIcYodwMJBaAC07XE6Wri +Sj3aQA3lnUAmAOcyvnWR3liqzol6Ea55/DW9ed56PT3CXGeCieufvxjX5t8vzmRClqg 8cfpmrLvZ+vEmi8yuYIIH8Yaj73tMZdUu7vNp0mUFBLmQhnBTnjUUdF2yiNgnmN1GIQ/ td6Ibm6SxdcgYFbuFso15WXAkztXzomkk3WhRLAEaVJ1FZfeZGg2crRWkLeVX0nsoNGC GmqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kTpTrDHo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r17si1247305ejz.238.2020.09.17.20.07.05; Thu, 17 Sep 2020 20:07:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kTpTrDHo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730623AbgIRDEx (ORCPT + 99 others); Thu, 17 Sep 2020 23:04:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:52296 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726625AbgIRCEk (ORCPT ); Thu, 17 Sep 2020 22:04:40 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B717E23718; Fri, 18 Sep 2020 02:04:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394679; bh=ieeBqnK2oYZAV53k1RC08bcmmz7yge6AxnLN1S72xxU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kTpTrDHoA8hqDa1f06zub2tjwwdGwLjPzPtkEEw1WySGxLpcA5GcwxiekHnfl9DOP oq//3YcfEsQDWhS4clhbQ7D+PNrV3HU6AF9hYNZVKtUiltyAoVcnxyyr7Yd0JoUZpF k3kjR+hGsMg8xskExSjV2ifaFxrAspmmCdW246Tc= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Colin Ian King , Sean Young , Mauro Carvalho Chehab , Sasha Levin , linux-media@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 169/330] media: tda10071: fix unsigned sign extension overflow Date: Thu, 17 Sep 2020 21:58:29 -0400 Message-Id: <20200918020110.2063155-169-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020110.2063155-1-sashal@kernel.org> References: <20200918020110.2063155-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 1953b00b3e487..685c0ac71819e 100644 --- a/drivers/media/dvb-frontends/tda10071.c +++ b/drivers/media/dvb-frontends/tda10071.c @@ -470,10 +470,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; -- 2.25.1