Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp522407lqt; Fri, 19 Apr 2024 02:56:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWhnX3abk+Onb4Ku+0NsGuC3KmCNXyNEpztzA049xQ/I/fjmalnBrg1L0w3PU9RL9yaW4i+7LmhbMlIJrbNoUbyT2brJSBD1N9nUXO42w== X-Google-Smtp-Source: AGHT+IFB2YBX/NCKht2/CqYolmUy8fSHfQtHBMpWl86HA15MPnCOIjdjE7eUXrqh4PoMVdm+ra+L X-Received: by 2002:a05:6a20:da89:b0:1a7:2e17:efd3 with SMTP id iy9-20020a056a20da8900b001a72e17efd3mr2279323pzb.5.1713520618235; Fri, 19 Apr 2024 02:56:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713520618; cv=pass; d=google.com; s=arc-20160816; b=Q8yQN5OwtTeW7RrL+BizR+VB4xSxJMwxmMq0FWSi8mzgFGiAs8WQcBm3GH35GxxoX8 b1mVbkobNHEAybRM3ktpDMbL6geADpJt6juMH6RnhT9Aw2ll7F++vfVtbwOc0qduXqQn W8RjFm8wMqw52J1Yzr5k8Xfm0bTBzKisRdPqDL+NUaXznw7o7ACkcu2uyuAkORdYMG8g YRmN3biiZyzNWLjCdMe7dhja/vaIj0IUhSteV4nuOyFqh2h9dIoVQFv60kQc9j92Cc6w oneRwKvineTrTsPvePgb46OzCdg+rfv6OzeaY0uYXDYPTO1I9aExuCfVCzZgS1G6dfew YHwA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=vmuUSFnHzqjHSVO6x2xCi4IdU77yIJvh23Ivq0XCHvQ=; fh=TOd0FMX5f6soK/b01m2KqcSCqqddYCaREHzyLPEsX98=; b=bYpqpaF0wg6eex4a5+jk9ne4Rx/npzfW9lpb/FrzE/KRfWiCFcne9pSDSzcUK1R9wF OLORjnwkcxGmD3VzJSZrVbzKRkASku4lZcoul4FOLj4rTrD68JQ285yUcjUntDiKtika gcSnD79aVa6c301dF5IkiaI5pa0xv8oJ2m+2AN99LSS7OQfvP+yj1yJaO0mEu25SxPf8 BN6dAZuAcqzdYD/rx4RkGCIjZDU6r4Yu3i4yNiMM3zSiUaHxwNwDApQcrl4wl3u5g6za rZ4+dcyLkMG9IziI8bG4cpSBprD3xy0+2xGGYl21LWeutrsSYbcQuQsbPyFFS4W6gPA7 peGw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=fkTLAX1A; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-151272-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-151272-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id j19-20020aa78dd3000000b006ecef03a767si2967453pfr.340.2024.04.19.02.56.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 02:56:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-151272-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=fkTLAX1A; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-151272-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-151272-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 94059283ABD for ; Fri, 19 Apr 2024 09:56:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 032DB133286; Fri, 19 Apr 2024 09:49:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="fkTLAX1A" Received: from mail-qk1-f175.google.com (mail-qk1-f175.google.com [209.85.222.175]) (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 C3701130E5C for ; Fri, 19 Apr 2024 09:49:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713520190; cv=none; b=gLD//+0/0dgnYgeiLsswOSpgekRhCTbyIWglv3OlLKciHISVcelOXM6sgwEJmhcVUpLQCFEHv3yh8zyCYQTVrwOppXXo2v4TsUJ2x9rXwbI3nxkRjaF0J5HrA2f+trwMPAy1fJ74l9kqdNufLPsIwJ8kKoNs3jDbCtxuDrjra/k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713520190; 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=B9RAyySapB5YI5jVN7ab6/E7n+/OoY+ao8yYTAL1ckRjkjgaz4LRsuS9vr/R+7jQDPJ9d79aGJhfYI0Suemljx1USt+/R9LlGxAWaeu7ws4/sZxPeqxSGNOHeFgXr+LXQNnIxo8YGFOMBIqZ8NZVvrHL8nc+zi8Zvv7JXvWB+gg= 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=fkTLAX1A; arc=none smtp.client-ip=209.85.222.175 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 Received: by mail-qk1-f175.google.com with SMTP id af79cd13be357-78edc49861aso124954485a.3 for ; Fri, 19 Apr 2024 02:49:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1713520188; x=1714124988; 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=fkTLAX1AOsZvhNrYs4pzfF+g3qT25dJu3IKhvdTzopFrQQoePV4MlxmLj3n3nZ0/HM A7l0a++14xaFQNQnEAjmKloJvPkfU2L2daz89mmVfFFzBle9vRg6UzEB9QPIfjT4DUmG Uac+zlI7rDdDxZMO48Bb7Qyt3lugaJpIeHKbU= 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=rb3PEC+rsIEnCV+1O8lUZzikavKVS27qVgjZaOMiwlllZ6vS9VzvlL57U6Y0Mil/EN HkFATBEjFxC4HNZfvOi6ScNPquqxiS3sXUiyxnQKXCgCZfef13mYkrzOgppiRg+R6PBD pxLm4id3Vph7FtsNisTJ90jF/i3x1Q3ZZV8TLa6hgTDfy2KeoItUmq3pYjqPplEs1mCV EUWN9DYYy4emx5QWJ6MEdS/5l8j/xYUea47tP8VyAAUK4B1a92bJzXCQDFJX3YGQP8U/ 1WDY3c8gXde92ZZbTSsa7PArY0gUHdmDkgMbwfFTDrt23C+ssTE0QwER5MOCaNzBopjm JaTw== X-Forwarded-Encrypted: i=1; AJvYcCVq0ocsoccooWzxotsnYiGeMIE1b7O0IGe84YznvCGo3LY7cRMFY3F1lLlzS8iLBALkQimOgCrT243chx3+ZFfo7sK2G3ZIQcIQ09Qw X-Gm-Message-State: AOJu0Ywx8GybhfXRyNRfb0F0+NX3C5JhiT3zgGJa/tb10C/659ewvF09 Iwtslf7Ho7u0raNCL0XSQa6ha0K5dqm2DMAOZaeO4Zqhf7wX5uNhaM6lyf5NXA== 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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 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 */ -- 2.44.0.769.g3c40516874-goog