mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
To: Antti Palosaari <crope@iki.fi>,
	Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Gustavo A. R. Silva" <garsilva@embeddedor.com>
Subject: [PATCH 1/8] rtl2832: fix potential integer overflow in rtl2832_set_frontend
Date: Mon, 29 Jan 2018 18:30:56 -0600	[thread overview]
Message-ID: <1c57e607fbde1e598b2ca9380889e9fc1be6daa4.1517268667.git.gustavo@embeddedor.com> (raw)
In-Reply-To: <cover.1517268667.git.gustavo@embeddedor.com>

Cast dev->pdata->clk to u64 in order to avoid a potential integer
overflow. This variable is being used in a context that expects
an expression of type u64.

Addresses-Coverity-ID: 1271223 ("Unintentional integer overflow")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
 drivers/media/dvb-frontends/rtl2832.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/dvb-frontends/rtl2832.c b/drivers/media/dvb-frontends/rtl2832.c
index 94bf5b7..eefc301 100644
--- a/drivers/media/dvb-frontends/rtl2832.c
+++ b/drivers/media/dvb-frontends/rtl2832.c
@@ -498,7 +498,7 @@ static int rtl2832_set_frontend(struct dvb_frontend *fe)
 	* RSAMP_RATIO = floor(CrystalFreqHz * 7 * pow(2, 22)
 	*	/ ConstWithBandwidthMode)
 	*/
-	num = dev->pdata->clk * 7;
+	num = (u64)dev->pdata->clk * 7;
 	num *= 0x400000;
 	num = div_u64(num, bw_mode);
 	resamp_ratio =  num & 0x3ffffff;
@@ -511,7 +511,7 @@ static int rtl2832_set_frontend(struct dvb_frontend *fe)
 	*	/ (CrystalFreqHz * 7))
 	*/
 	num = bw_mode << 20;
-	num2 = dev->pdata->clk * 7;
+	num2 = (u64)dev->pdata->clk * 7;
 	num = div_u64(num, num2);
 	num = -num;
 	cfreq_off_ratio = num & 0xfffff;
-- 
2.7.4

  reply	other threads:[~2018-01-30  0:51 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-30  1:07 [PATCH resend 0/8] fix potential integer overflows Gustavo A. R. Silva
2018-01-30  0:30 ` Gustavo A. R. Silva [this message]
2018-01-30  0:31 ` [PATCH 2/8] dvb-frontends: ves1820: fix potential integer overflow Gustavo A. R. Silva
2018-01-30  0:31 ` [PATCH 3/8] i2c: max2175: fix potential integer overflow in max2175_set_nco_freq Gustavo A. R. Silva
2018-01-30  0:32 ` [PATCH 4/8] i2c: ov9650: fix potential integer overflow in __ov965x_set_frame_interval Gustavo A. R. Silva
2018-02-02  9:22   ` Sakari Ailus
2018-01-30  0:32 ` [PATCH 5/8] pci: cx88-input: fix potential integer overflow Gustavo A. R. Silva
2018-01-30  0:32 ` [PATCH 6/8] rockchip/rga: fix potential integer overflow in rga_buf_map Gustavo A. R. Silva
2018-01-30  0:33 ` [PATCH 7/8] platform: sh_veu: fix potential integer overflow in sh_veu_colour_offset Gustavo A. R. Silva
2018-01-30  0:33 ` [PATCH 8/8] platform: vivid-cec: fix potential integer overflow in vivid_cec_pin_adap_events Gustavo A. R. Silva
2018-01-30  7:21   ` Hans Verkuil
2018-01-30  8:51     ` Gustavo A. R. Silva
2018-01-30  9:57       ` Hans Verkuil
2018-01-30 10:55         ` Gustavo A. R. Silva
2018-01-30 11:15           ` Hans Verkuil
2018-01-30 11:43             ` Gustavo A. R. Silva
2018-01-30 11:50               ` Hans Verkuil
2018-01-30 11:57                 ` Gustavo A. R. Silva

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1c57e607fbde1e598b2ca9380889e9fc1be6daa4.1517268667.git.gustavo@embeddedor.com \
    --to=gustavo@embeddedor.com \
    --cc=crope@iki.fi \
    --cc=garsilva@embeddedor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®