Message ID | 20240429-fix-cocci-v3-25-3c4865f5a4b0@chromium.org (mailing list archive) |
---|---|
State | Not Applicable |
Headers | show
Received: from mail-qk1-f174.google.com (mail-qk1-f174.google.com [209.85.222.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3D8F2126F03 for <linux-arm-msm@vger.kernel.org>; Mon, 29 Apr 2024 15:05:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714403122; cv=none; b=ooLRgVkdsRw4pcDeTUpmnBmeSErrLhbgBzt18LD2TPYSKMcuKy4Rfw7AJ+VIbS2g/DrZFn4njL0PoTNSqzDEEtB/I1pd1M4IIJNGOXiimWxGx+PPnWdaabAL55kBw+zX+y2kCaidvnQhonE5JfAhlZwaoHUCGuSuk76jDGMGv50= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714403122; c=relaxed/simple; bh=o6W/vqiRX5/Lnl4n/KralCP6cqo+hBRj8ijp3AUHwA0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gRr7g+rlJLc9ertZW0UlkM0ekTwA//XRRBsGAGvPEgEFVmXHlfn4D2GXxWzLE8Lt3vulceyBHbSTZ3J+jv2JuiBfebdP8jEC1AVmOTdnPvtA3SFyn3SQ+3wIH9LLWjhWiIaHlP3/JkjJIX6tpd+u7K2iK+xtiVjkKmK0xd2g6rU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=YXYPKXbK; arc=none smtp.client-ip=209.85.222.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="YXYPKXbK" Received: by mail-qk1-f174.google.com with SMTP id af79cd13be357-78edc3e7cd9so346884485a.1 for <linux-arm-msm@vger.kernel.org>; Mon, 29 Apr 2024 08:05:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1714403110; x=1715007910; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=vmuUSFnHzqjHSVO6x2xCi4IdU77yIJvh23Ivq0XCHvQ=; b=YXYPKXbKU9D1Wr+R+YuadCPeTk537QjPfyCnlNBMkKLrtoVkyKRAvzqdHHI4QDiUrn 2s3bcoK8DRGE9d1CUJlu1/k1qF7N+wPe0l78GiF8z9nHAetxr+ir3ZN3upCs4BwLPDFB vQ5ymfpy8QhJxBKPPx5LoekuAQe0s9OiHtm2w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714403110; x=1715007910; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vmuUSFnHzqjHSVO6x2xCi4IdU77yIJvh23Ivq0XCHvQ=; b=OaGV70c/1lm5JTRV+szKPa7Bgw8ua6ZB6uGxvpb7MY8DsWq500s5/gKD6q49Wk50x1 ugyEZh47LQkKD/qIaHVYQ67Bk+X7818AL32EYvziyg50MzTDMPVrhKrJzTkCmDQ1IJbA vH6Xwa6cNt+Hqx3ylNPmTHxWqHlVzcJgLQIjNwecXzrqpT2Pt0o+f/D+gekF4Le6Q0FE XTwINq4TRL04O5o/Q0oN+3XphMPYVVZLbOZAwFMo4Avfl5I66YUDdaiM5j521CpFRmwX DEi5Toa2e58cr1D10GjqT35CSeOP3Z/iPxv8pLA+bJPLIxAOzrlbVxcCLRi//4OS8okO bEmA== X-Forwarded-Encrypted: i=1; AJvYcCXZv7w7QquYSk6s61LUrqqTAegBxZpjXaGlolrpm2au1XGqku4wUu8QY+aUk/d9vKIJdG01RpVSVS7taxhP2LYfqKSd43yM8M8dOBYTqg== X-Gm-Message-State: AOJu0YyppHNBYZBRaq4b08CrNx7/grmBm2yZNYamjPzqMgt9Sv370b2Q gNPFmv/0fHmuod0xQOq66oczkUD1fMjAbYXW1jWBpuuEX/mJ9MArLU8M3rQdGQ== X-Google-Smtp-Source: AGHT+IH9sz0tcRc5gxc3Hn2yH4aEBZFdiRiwY4P/N3aVh4I90x1YrGS0c1n2StA1reM2wgrnpB/ryg== X-Received: by 2002:a05:620a:1665:b0:790:9e62:787f with SMTP id d5-20020a05620a166500b007909e62787fmr11023549qko.28.1714403110567; Mon, 29 Apr 2024 08:05:10 -0700 (PDT) Received: from denia.c.googlers.com (114.152.245.35.bc.googleusercontent.com. [35.245.152.114]) by smtp.gmail.com with ESMTPSA id p7-20020a05620a056700b0078d3b9139edsm10568591qkp.97.2024.04.29.08.05.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 08:05:10 -0700 (PDT) From: Ricardo Ribalda <ribalda@chromium.org> Date: Mon, 29 Apr 2024 15:05:04 +0000 Subject: [PATCH v3 25/26] media: dvb-frontends: tda10048: Fix integer overflow Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: <linux-arm-msm.vger.kernel.org> List-Subscribe: <mailto:linux-arm-msm+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-arm-msm+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240429-fix-cocci-v3-25-3c4865f5a4b0@chromium.org> References: <20240429-fix-cocci-v3-0-3c4865f5a4b0@chromium.org> In-Reply-To: <20240429-fix-cocci-v3-0-3c4865f5a4b0@chromium.org> To: Martin Tuma <martin.tuma@digiteqautomotive.com>, Mauro Carvalho Chehab <mchehab@kernel.org>, Laurent Pinchart <laurent.pinchart@ideasonboard.com>, Hugues Fruchet <hugues.fruchet@foss.st.com>, Alain Volmat <alain.volmat@foss.st.com>, Maxime Coquelin <mcoquelin.stm32@gmail.com>, Alexandre Torgue <alexandre.torgue@foss.st.com>, Paul Kocialkowski <paul.kocialkowski@bootlin.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Chen-Yu Tsai <wens@csie.org>, Jernej Skrabec <jernej.skrabec@gmail.com>, Samuel Holland <samuel@sholland.org>, Sakari Ailus <sakari.ailus@linux.intel.com>, Thierry Reding <thierry.reding@gmail.com>, Jonathan Hunter <jonathanh@nvidia.com>, Sowjanya Komatineni <skomatineni@nvidia.com>, Luca Ceresoli <luca.ceresoli@bootlin.com>, Matthias Brugger <matthias.bgg@gmail.com>, AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>, Hans Verkuil <hverkuil@xs4all.nl>, Sergey Kozlov <serjk@netup.ru>, Abylay Ospan <aospan@netup.ru>, Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>, Dmitry Osipenko <digetx@gmail.com>, Benjamin Mugnier <benjamin.mugnier@foss.st.com>, Sylvain Petinot <sylvain.petinot@foss.st.com>, Stanimir Varbanov <stanimir.k.varbanov@gmail.com>, Vikash Garodia <quic_vgarodia@quicinc.com>, Bryan O'Donoghue <bryan.odonoghue@linaro.org>, Bjorn Andersson <andersson@kernel.org>, Konrad Dybcio <konrad.dybcio@linaro.org> Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-msm@vger.kernel.org, Ricardo Ribalda <ribalda@chromium.org>, Dan Carpenter <dan.carpenter@linaro.org> X-Mailer: b4 0.12.4 |
Series |
media: Fix coccinelle warning/errors
|
expand
|
diff --git a/drivers/media/dvb-frontends/tda10048.c b/drivers/media/dvb-frontends/tda10048.c index 5d5e4e9e4422..3e725cdcc66b 100644 --- a/drivers/media/dvb-frontends/tda10048.c +++ b/drivers/media/dvb-frontends/tda10048.c @@ -410,6 +410,7 @@ static int tda10048_set_if(struct dvb_frontend *fe, u32 bw) struct tda10048_config *config = &state->config; int i; u32 if_freq_khz; + u64 sample_freq; dprintk(1, "%s(bw = %d)\n", __func__, bw); @@ -451,9 +452,11 @@ static int tda10048_set_if(struct dvb_frontend *fe, u32 bw) dprintk(1, "- pll_pfactor = %d\n", state->pll_pfactor); /* Calculate the sample frequency */ - state->sample_freq = state->xtal_hz * (state->pll_mfactor + 45); - state->sample_freq /= (state->pll_nfactor + 1); - state->sample_freq /= (state->pll_pfactor + 4); + sample_freq = state->xtal_hz; + sample_freq *= state->pll_mfactor + 45; + do_div(sample_freq, state->pll_nfactor + 1); + do_div(sample_freq, state->pll_pfactor + 4); + state->sample_freq = sample_freq; dprintk(1, "- sample_freq = %d\n", state->sample_freq); /* Update the I/F */
state->xtal_hz can be up to 16M, so it can overflow a 32 bit integer when multiplied by pll_mfactor. Create a new 64 bit variable to hold the calculations. Reported-by: Dan Carpenter <dan.carpenter@linaro.org> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> --- drivers/media/dvb-frontends/tda10048.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)