From mboxrd@z Thu Jan 1 00:00:00 1970 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 0FEFFD24463 for ; Fri, 11 Oct 2024 00:46:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Date:To:Cc:From:Subject: References:In-Reply-To:Content-Transfer-Encoding:MIME-Version:Content-Type: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=XjFS3eA8/FouqkZPS/NBIKTe9Kj7Em57mbGV+JmXn5o=; b=XUXRoWCnc3CpYyxeISj9N6o7fX qeUdHXjMi9aGsmg+hXG/mG+Gp5wPExkcQignR78ZVxlNFFoTOtjzkEdhz5EMF55RO3V+2pZwJowNU aYPD7aLHJ08R8VBk9IojwDqnytpn6Y7ptJ3L/nPb7mREV6MbJCUTuZCxOShpYLJ4/YBKARmhYSv+8 CGmE8Drp9EaLdFsF7KWpcVQb4WC4G38MkQIodHHSK61HLeOIOkUDFpJGK6kN0RO98/SSRAy+0QxWK tVLN6RorFIoqwhSrq6HtbQgLZvJkWoHANI4Ifa2Vbfx1MR1yL5eat2ZIrNUycAaenRWXWTfnVLKz2 v+1EdcUQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1sz3nd-0000000Epwf-45di; Fri, 11 Oct 2024 00:46:33 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1sz1Xf-0000000EX4Z-0yC5; Thu, 10 Oct 2024 22:21:55 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Date:To:Cc:From:Subject:References: In-Reply-To:Content-Transfer-Encoding:MIME-Version:Content-Type:Message-ID: Sender:Reply-To:Content-ID:Content-Description; bh=XjFS3eA8/FouqkZPS/NBIKTe9Kj7Em57mbGV+JmXn5o=; b=QF9zbXm51p44rRgClZUB+90b6h vBDaPeVrEhbYEXLIP2ajngbeSoIwnXcUZNWehH/WveGlngTDVyiIOu8hdf/5KpesoTpK7THpDZThe m6LlWgQ5AiH5LFhrfFCEVacCOdl+BWfXzrBx6yoPnOtQDHpvI+Pg3BE2ddes9jFqnZycG+mnRaCdZ mvaVLzZnnPjMj2Yt5ocoLnaUoFgKh+3pvRUOEejz9xkDXdgCOhDYuwkiyS43UfMFL/UDgQxcBFzEg vWGb+uMnFYj+RvhWPwUt68VQEgVhk5D7RL3nYo9OKYUTm+PYIghLTIgh1K7a12xONoLRBMUUSqz3y f5bupJwQ==; Received: from nyc.source.kernel.org ([2604:1380:45d1:ec00::3]) by desiato.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1sz1Xb-00000005hPj-2g6S; Thu, 10 Oct 2024 22:21:53 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 47CD3A41813; Thu, 10 Oct 2024 22:21:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8E95AC4CEC5; Thu, 10 Oct 2024 22:21:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728598907; bh=oBDNpYeXUb77o/FNxNq8pnU5gAz9EMoLLWFXUk5bfy0=; h=In-Reply-To:References:Subject:From:Cc:To:Date:From; b=GZPrhQC28VWzXwSBj/v7nkqdYJ/5RaOhwlNuIdUPmqtovSNJAzaDOg4FHyMBwEYpV WK+v0bYwfJD0FELKbJy37A7rCThPC1Yn2JbFxSZowJuAdk5Hc/dBhU2YxmpYQJ9wXy 14dA0iJmVopOUba810unxjINPWkgw6Dc8a6UoIG2tlhdgYRiq9v+ORjYyNKG3j9crE 3iVZzWFtpFG+nnf2yN04LieDzxJK+PwSxLWDcMrPiESNs4gEizDThm0X5AILaYGaOP TbqnuDdxXf/ea1xK9shNT+bYmPppk11f3vecIFFY5u6ajs7RTeGaPhTKoehceujFjK 8oTtXpIj89SZg== Message-ID: Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: <20240910130640.20631-1-abelova@astralinux.ru> References: <20240910130640.20631-1-abelova@astralinux.ru> Subject: Re: [PATCH] clk: actions: prevent overflow in owl_pll_recalc_rate From: Stephen Boyd Cc: Anastasia Belova , Andreas =?utf-8?q?F=C3=A4rber?= , Manivannan Sadhasivam , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-actions@lists.infradead.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org, stable@vger.kernel.org To: Anastasia Belova , Michael Turquette Date: Thu, 10 Oct 2024 15:21:45 -0700 User-Agent: alot/0.10 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241010_232152_150431_8D3407FC X-CRM114-Status: GOOD ( 12.46 ) 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 Quoting Anastasia Belova (2024-09-10 06:06:40) > In case of OWL S900 SoC clock driver there are cases > where bfreq =3D 24000000, shift =3D 0. If value read from > CMU_COREPLL or CMU_DDRPLL to val is big enough, an > overflow may occur. >=20 > Add explicit casting to prevent it. >=20 > Found by Linux Verification Center (linuxtesting.org) with SVACE. >=20 > Fixes: 2792c37e94c8 ("clk: actions: Add pll clock support") > Cc: =20 Seems like we don't need these tags because it can't overflow. > Signed-off-by: Anastasia Belova > --- > drivers/clk/actions/owl-pll.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) >=20 > diff --git a/drivers/clk/actions/owl-pll.c b/drivers/clk/actions/owl-pll.c > index 155f313986b4..fa17567665ec 100644 > --- a/drivers/clk/actions/owl-pll.c > +++ b/drivers/clk/actions/owl-pll.c > @@ -104,7 +104,7 @@ static unsigned long owl_pll_recalc_rate(struct clk_h= w *hw, > val =3D val >> pll_hw->shift; > val &=3D mul_mask(pll_hw); > =20 > - return pll_hw->bfreq * val; > + return (unsigned long)pll_hw->bfreq * val; I'm lost. Did you intend to cast this to a u64?