From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (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 19792152DF2 for ; Fri, 3 May 2024 11:55:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714737318; cv=none; b=GWDZtv7Fr+eZxHTVmAA1ObL47t6R7DAuVWrX5EIM+lofzmywP2Qwt9QIoyDpZ+DLMmCu2su2e9lI/3F+JSaMCtpRCfBo3McT1AEQmUIfYGQx1JNIZQtw4UFejVRMQ+i9n+kkOkpsJo/s0xRsHtj3VuUCsIQRQwMM3JQ20Gbv+BE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714737318; c=relaxed/simple; bh=3oofEKzoY8Dgctp4SevRDAbz9giFPEyX/mlb/8O3MRw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=s1lXg+chWa8GJNjvoKUclLFdeHLax6ZmagAUawxnXD18nYCjDGcUcF1o0skPaTPqCzMjwNovbtcQPNZaM/INnxQOh7VowhM6LbK7WCOo5EaX5Cqkk5XGWSFb4z/ndAB2gjonHV3z3fsf1f49h+vODhsBSxAWyBvixz/wsqth6pM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=J27cHOpg; arc=none smtp.client-ip=209.85.128.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="J27cHOpg" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-41bab13ca4eso48749385e9.1 for ; Fri, 03 May 2024 04:55:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714737313; x=1715342113; darn=lists.linux.dev; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=ejcxvyIN9Gt9hs/CP6yU9CZUBAq0kOYwH6s0PyoHfGQ=; b=J27cHOpg7ESKdRIVLnDfy00JiGZPCIUmhXsEgiwRE4nSkvYRQ0Yvi9CKzi7WcHnvWm TQmsIO0h3Q0Ez0GjM+mtKaS0KT22vKiqLrVCKsWDs/LSZkX1nsYaK3ZHJSOe+0fXyhhI m2OMi1jJVhH4dyJFCFgm0k4Lxr1zJLhMzc2gBy1nP668ec7B3GOPDdOw8BiPUf+pWG53 mGHlUSSfjWFAtA6leG1XxAElcqtC9tkz7lXKu+AVNvtr5xJu+3lWHHvDcr8M1vebRW4W cziCT2T0Q5hvE3cxLl61UMLQUEEA+yfYp01gkzUV42uO4msCpR4sN3ZoWieanrwtY8Df fbNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714737313; x=1715342113; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ejcxvyIN9Gt9hs/CP6yU9CZUBAq0kOYwH6s0PyoHfGQ=; b=J0Ffdfk+W5jYFbYScsS7f1uEuHekBseLfNxMsQpNOa0NiVbnXdPGU+3MlHwDb2lhFF MNBRopP1eN8BhESbTlWRm+X0eCtaaqd3cx5Pze4Fxfh/ahO11u3LL+nO5T31d4sdT3od D2Q8uLWKM0YquD9Ankf3HVzFL9GAh0ug1OdgxED31ZY1cCMQsjcZwxQfVJ58Lkq9J+Ex eYZjo+07Bl73QQU4gS+gJbe65jr0LRVQg/KZrEIb/NwEWeqvXwkSZNkumUa4w9ALbF4T xrm+CpkjjDAXrePmKi1e0APl4bQ33DDcXiNiFQx4n1aT/5cuFNhMWVnU3U1YFq6oaWxu gUvA== X-Forwarded-Encrypted: i=1; AJvYcCUzlwj4tbJcNs288ecZsn3x+zYB705EQPmS92UN6r7HAUQLbeWOet1fuSL82+97qf/x8UAWRKEf3y+STiwr11mwYkV/EH6b9PszAwY2Pg== X-Gm-Message-State: AOJu0YxE55YxchPaXXRNIQdsBd2TdSRz/pg3px4zIqPHgRcozW/2piPz i1/ngt0lilzGgt/qBpmwU40yni5MqtZo03KnFUojsjm5Jr/5gtIGmH5fpgo0FW0= X-Google-Smtp-Source: AGHT+IHjyMa7ooctRLN/1tdS/gx79TA23M2UYYTNE+3A8Wfu/afPHupfSN+yShlxrDD3Ur4rmUCBww== X-Received: by 2002:a05:600c:5118:b0:41a:34c3:2297 with SMTP id o24-20020a05600c511800b0041a34c32297mr1821832wms.5.1714737313152; Fri, 03 May 2024 04:55:13 -0700 (PDT) Received: from localhost ([102.222.70.76]) by smtp.gmail.com with ESMTPSA id k8-20020a05600c1c8800b00418a6d62ad0sm9213606wms.34.2024.05.03.04.55.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 04:55:12 -0700 (PDT) Date: Fri, 3 May 2024 14:55:09 +0300 From: Dan Carpenter To: Mauro Carvalho Chehab Cc: Ricardo Ribalda , Martin Tuma , 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 , 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 Subject: Re: [PATCH v3 26/26] media: dvb-frontends: tda10048: Make the range of z explicit. Message-ID: References: <20240429-fix-cocci-v3-0-3c4865f5a4b0@chromium.org> <20240429-fix-cocci-v3-26-3c4865f5a4b0@chromium.org> <20240503112758.763d8d31@sal.lan> Precedence: bulk X-Mailing-List: linux-staging@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240503112758.763d8d31@sal.lan> On Fri, May 03, 2024 at 11:27:58AM +0100, Mauro Carvalho Chehab wrote: > Em Mon, 29 Apr 2024 15:05:05 +0000 > Ricardo Ribalda escreveu: > > > We do not expect the sample_freq to be over 613MHz. > > > > Found by cocci: > > drivers/media/dvb-frontends/tda10048.c:345:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead. > > > > Signed-off-by: Ricardo Ribalda > > --- > > drivers/media/dvb-frontends/tda10048.c | 4 +++- > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/media/dvb-frontends/tda10048.c b/drivers/media/dvb-frontends/tda10048.c > > index 3e725cdcc66b..1886f733dbbf 100644 > > --- a/drivers/media/dvb-frontends/tda10048.c > > +++ b/drivers/media/dvb-frontends/tda10048.c > > @@ -328,7 +328,8 @@ static int tda10048_set_wref(struct dvb_frontend *fe, u32 sample_freq_hz, > > u32 bw) > > { > > struct tda10048_state *state = fe->demodulator_priv; > > - u64 t, z; > > + u32 z; > > + u64 t; > > > > dprintk(1, "%s()\n", __func__); > > > > @@ -341,6 +342,7 @@ static int tda10048_set_wref(struct dvb_frontend *fe, u32 sample_freq_hz, > > /* t *= 2147483648 on 32bit platforms */ > > t *= (2048 * 1024); > > t *= 1024; > > + /* Sample frequency is under 613MHz */ > > Are you sure about that? Some DVB devices have very high frequency > clocks, specially if they're also used for satellite, so I can't > be sure by just looking at the driver's code. > > Also, we had already a bunch of regressions with "fixes" like this > that actually broke frontend drivers. This patch preserves the existing behavior. The sample_freq_hz variable is a u32 so, in the original code, z couldn't have been more than U32_MAX even though it was declared as a u64. It's possible that the original code was wrong. We have seen that in other places in this patchset. Adding a note about the datasheet is also a good idea. regards, dan carpenter