From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2AC1B1DDCE; Tue, 16 Jul 2024 16:06:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721145980; cv=none; b=Tt4m3tbUamMyxuTT6Xl1xq2iKqdStT0lN24SUgzd8CiMF+4yc40Ix62K85VdW14FkWQv3ZgnCc1KuPo+vN4o1beParfKD4yaeXkAYOuV3rOaWYTE7N7jjya0iRhVT2OTKsYKa4gEd9c2kq4RawMjOp9VZQvgLE3Qxy54SRXRnFg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721145980; c=relaxed/simple; bh=I79kvoe+YHnRmH4PZ9ppVQHYjDNnopNjEJHtZ0bsu78=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sJaKmnlsYF3P8xu4Bu6gGk8GjGu2BqUr2zJQVsoxO7Un6J9ENlR+mmRvzm7ex1rZTclamnZ771MumJHGYse6n30OQsY4zOGJ7R6ngFy4RaN+O3wVLN5IgHBPZ5AF4NxG97nx9X+kVnjCm1v4/djIQAg8j5OztLIr0UWQ4Yd/274= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=F/2ZZ5Qc; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="F/2ZZ5Qc" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9D80AC116B1; Tue, 16 Jul 2024 16:06:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1721145980; bh=I79kvoe+YHnRmH4PZ9ppVQHYjDNnopNjEJHtZ0bsu78=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F/2ZZ5Qc0srrT10VlxbntXsHqziWkx11m15fUQ/JxfK2+FWPPGv5nTykzSmEdPJm2 XybrZbCVxIZ0m8+75kwBwUjIa5NDVtxTktEt4g1Ycg93cxy9DRTDqHyLQ22Gf7d+F2 r97L5S55Gwb8g3GruTghgT+xh6PO3AnxwJUNMoeU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Dan Carpenter , Ricardo Ribalda , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.15 020/144] media: dvb-frontends: tda10048: Fix integer overflow Date: Tue, 16 Jul 2024 17:31:29 +0200 Message-ID: <20240716152753.310819713@linuxfoundation.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240716152752.524497140@linuxfoundation.org> References: <20240716152752.524497140@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ricardo Ribalda [ Upstream commit 1aa1329a67cc214c3b7bd2a14d1301a795760b07 ] 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. Link: https://lore.kernel.org/linux-media/20240429-fix-cocci-v3-25-3c4865f5a4b0@chromium.org Reported-by: Dan Carpenter Signed-off-by: Ricardo Ribalda Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/dvb-frontends/tda10048.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/media/dvb-frontends/tda10048.c b/drivers/media/dvb-frontends/tda10048.c index f1d5e77d5dcce..db829754f1359 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 */ -- 2.43.0