From patchwork Fri Apr 19 09:48:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13636102 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5CBB9C4345F for ; Fri, 19 Apr 2024 09:53:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=IcGMDNEQDU9R3leVQWEAb8sk2hAlmfSZJWYPF5l3WJQ=; b=0gITz2oIEOymZx 86UsXBcKw4zfTOFNGFQ6R+ur1/O3DTO3VD27SXULaLyZT/uJV+JXYaRoW731Y1oRaTzqB5JfzCJkm 1U60clw3aXiDGamXq2vihTh/7lLTuKmKvQQRPwCPP4ehyn9e+khVWgkPIs9LkxFvxjyUpO7jc6cKh B5w1+SpWEETC+tNy5b6aoDJm5ZVH2riyxCHMGpdprnPRBS8VO9lWyg1u/0bNn0QhKhN1NpvnRaa7O 8/cbH16raIpIxv/rSPkTX1OCkqOuhR9/sR6ogRjBAUdXnjluA/S2i9I5ZrooKh/FUeS8Sr7DSlUkY Nex0lWQmhs9Vfd+lEawQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxkvf-00000005B8L-2c84; Fri, 19 Apr 2024 09:53:11 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxksU-000000059H8-3Hkj for linux-arm-kernel@bombadil.infradead.org; Fri, 19 Apr 2024 09:49:54 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Sender:Reply-To:Content-ID:Content-Description; bh=vmuUSFnHzqjHSVO6x2xCi4IdU77yIJvh23Ivq0XCHvQ=; b=Jr4piowM4YJJ9M9e8n6UaRMj/4 6KWP2AdJ5LVEF+fIdtPRzyF8B3viwVrkSkZf37g74ZceQxlzUc+QWVZr+8KUWD4PTqByyu0IubqlR 1oNSOA6pSav4DnIJj5RF53IQKfewINlmSLYlQqAbJAYQCaVdJ+VNWOc1ZuLgaoZiLCKwiPcv3dkc2 nomVsbH26bO3udEXuoNAVg6WxZLgXHgyDrI/43KqyAZsT8fJfJPokbsCShOk00mkAQzOrH/bw7hRr Oq07abH3Xbbn0mId1sM/7mgUX197PEHFV+XeOmUmAm1wvMdsIxY0cpn2uCiTvWmXTjdjb/dFnBBxZ KnYvfbIg==; Received: from mail-qk1-x735.google.com ([2607:f8b0:4864:20::735]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxksQ-0000000COU1-17ou for linux-arm-kernel@lists.infradead.org; Fri, 19 Apr 2024 09:49:53 +0000 Received: by mail-qk1-x735.google.com with SMTP id af79cd13be357-78f05aec21cso124242485a.0 for ; Fri, 19 Apr 2024 02:49:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1713520188; x=1714124988; darn=lists.infradead.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=XJrEwUu97o34kOkXfzNciiwc2iABoLWazViav10YUhBHcd2hYF8EBRDo/uQl36WetG 0Z3Sf9Pq9hYcU2N1tMRkDle+5dci2b8fmXL94UbU7FjLmbd0/CbpSNyGqHwpWzPGzedI eDbljVWqh9BccX2oSMziuwdSIcZ3eBjeqBCUo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713520188; x=1714124988; 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=ZLoFi2VEJr0+awlpjbl2nsmZbLKCnKS719gPfYTTPi1E1Rc/iAfzbmwArAHjEiDm26 jCXrWevTua24/mK4GR5DSUwPcGgzCJ5fRTTqJ9kuBukCBcrsnq51EgHtjzcQC/liOleX yc6CAFkfb312AneqXRRMQthibRzQBHE03gY+8nuJZ2DBoDC6pFU1mXpyx5FIXbnd8oEi q+ooJBAL2a6coRdhhTO1j3oThKZjoTlUwagcnQ9kD06L15UxOLmwU+SypvpnvBKMf9Rg S9B47NdObCNoVlNoq/+dwZsIncrVpWC30T9j55/5LxxyedWBeR/Tx3SSF1K7+mcGjtf3 EQ+g== X-Forwarded-Encrypted: i=1; AJvYcCWwgszgci456Hp3Ee6jSLmdcXjXC4w+Q5v/LBGpEP+M/bvshwUzR2o0y2yOE56GAiwJ9/IryTd3+TA6kovGg5zDnc4E0TisT9zheu7nP4hNe4U2P1I= X-Gm-Message-State: AOJu0YzFbdUUQ2WqBeK6gw+UkJMSbj4znUcF+4qSvCNNuGGAz71xmD7E yH/koK7/M3xyAm8CKUECW/C9SI4e86/Dua7MuJ2zryEvc0zNnnIcqYPf94eGaw== X-Google-Smtp-Source: AGHT+IGwmCCN5wh4NaLa8aArMkOF/G4Igcbkk8uWKtclUOXaJ3Z6Gx5Noog7Zc3uSUISJQ5MgoV6TQ== X-Received: by 2002:ae9:f50d:0:b0:78f:1044:bcc8 with SMTP id o13-20020ae9f50d000000b0078f1044bcc8mr1806809qkg.61.1713520187814; Fri, 19 Apr 2024 02:49:47 -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 dt14-20020a05620a478e00b0078d735ca917sm1434532qkb.123.2024.04.19.02.49.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 02:49:47 -0700 (PDT) From: Ricardo Ribalda Date: Fri, 19 Apr 2024 09:48:11 +0000 Subject: [PATCH v2 25/26] media: dvb-frontends: tda10048: Fix integer overflow MIME-Version: 1.0 Message-Id: <20240419-fix-cocci-v2-25-2119e692309c@chromium.org> References: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> In-Reply-To: <20240419-fix-cocci-v2-0-2119e692309c@chromium.org> To: Martin Tuma , Mauro Carvalho Chehab , Laurent Pinchart , Hugues Fruchet , Alain Volmat , Maxime Coquelin , Alexandre Torgue , Paul Kocialkowski , Greg Kroah-Hartman , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Sakari Ailus , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , Matthias Brugger , AngeloGioacchino Del Regno , Hans Verkuil , Sergey Kozlov , Abylay Ospan , Ezequiel Garcia , Dmitry Osipenko , Benjamin Mugnier , Sylvain Petinot , Stanimir Varbanov , Vikash Garodia , Bryan O'Donoghue , Bjorn Andersson , Konrad Dybcio 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 , Dan Carpenter X-Mailer: b4 0.12.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240419_104951_510739_3284AD17 X-CRM114-Status: GOOD ( 13.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Signed-off-by: Ricardo Ribalda --- 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 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 */