From patchwork Mon Jan 20 08:47:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anastasia Belova X-Patchwork-Id: 13944842 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 C0905C02185 for ; Mon, 20 Jan 2025 08:49:16 +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:Content-Transfer-Encoding: MIME-Version:Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=+ywE2R10zKr9VN7mkwWF3E7f/EcAjg3vrUR6GPA4k3o=; b=ZYLOzbA89tdKJ4WjH40btOJsYn Tco4gtQ/x5rcDa3YR2IdFgAa+hv4NdWsPwnyPSo0gFNfOshABoJ/U8xqjtpnV0jvbLjEJRjYvE0+b DQVCOIww3KcfUtmrrE4i2B1QfBf6w7XDZcJs89jFet7zlFnNxT5HdHCCBQ9+wwH7den2q9f3eeZpl f2xb4+XQ2L3hCrqs4P/7wU0jnJN3oO+kKeEyI+UDEqwyJkUsdYw1yYAgAtjjh2kOkVZFzDkXDDKue mprNrMu8uYju0pmdK0iXCL5qGntRIvjVKbIok1B6FqQ+LjTxWBxVGKV8NwR035ejG1e2lDBTOj2+B 0N7twauQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tZnSz-000000053T7-1SwK; Mon, 20 Jan 2025 08:49:05 +0000 Received: from mail-gw02.astralinux.ru ([195.16.41.108]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tZnRf-000000053Nl-3bMQ for linux-arm-kernel@lists.infradead.org; Mon, 20 Jan 2025 08:47:45 +0000 Received: from gca-msk-a-srv-ksmg02.astralinux.ru (localhost [127.0.0.1]) by mail-gw02.astralinux.ru (Postfix) with ESMTP id 705AC1F418; Mon, 20 Jan 2025 11:47:35 +0300 (MSK) Received: from new-mail.astralinux.ru (gca-yc-ruca-srv-mail05.astralinux.ru [10.177.185.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail-gw02.astralinux.ru (Postfix) with ESMTPS; Mon, 20 Jan 2025 11:47:31 +0300 (MSK) Received: from localhost.localdomain (unknown [10.177.20.106]) by new-mail.astralinux.ru (Postfix) with ESMTPA id 4Yc3qz6SgYz1c0sD; Mon, 20 Jan 2025 11:47:27 +0300 (MSK) From: Anastasia Belova To: =?utf-8?q?Emilio_L=C3=B3pez?= Cc: Anastasia Belova , Michael Turquette , Stephen Boyd , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Hans de Goede , Maxime Ripard , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org Subject: [PATCH] clk: sunxi: add explicit casting to prevent overflow Date: Mon, 20 Jan 2025 11:47:16 +0300 Message-ID: <20250120084719.63116-1-abelova@astralinux.ru> X-Mailer: git-send-email 2.47.0 MIME-Version: 1.0 X-KSMG-AntiPhishing: NotDetected X-KSMG-AntiSpam-Auth: dkim=none X-KSMG-AntiSpam-Envelope-From: abelova@astralinux.ru X-KSMG-AntiSpam-Info: LuaCore: 49 0.3.49 28b3b64a43732373258a371bd1554adb2caa23cb, {Tracking_arrow_text}, {Tracking_from_domain_doesnt_match_to}, d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;127.0.0.199:7.1.2;new-mail.astralinux.ru:7.1.1;astralinux.ru:7.1.1, FromAlignment: s X-KSMG-AntiSpam-Interceptor-Info: scan successful X-KSMG-AntiSpam-Lua-Profiles: 190443 [Jan 20 2025] X-KSMG-AntiSpam-Method: none X-KSMG-AntiSpam-Rate: 0 X-KSMG-AntiSpam-Status: not_detected X-KSMG-AntiSpam-Version: 6.1.1.7 X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.1.0.7854, bases: 2025/01/20 05:14:00 #27075937 X-KSMG-AntiVirus-Status: NotDetected, skipped X-KSMG-LinksScanning: NotDetected X-KSMG-Message-Action: skipped X-KSMG-Rule-ID: 1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250120_004744_067254_659A2B08 X-CRM114-Status: GOOD ( 10.54 ) 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 If n = 255, the result of multiplication of n and 24000000 may not fit int type. Add explicit casting to prevent overflow. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 6424e0aeebc4 ("clk: sunxi: rewrite sun9i_a80_get_pll4_factors()") Signed-off-by: Anastasia Belova --- drivers/clk/sunxi/clk-sun9i-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/clk/sunxi/clk-sun9i-core.c b/drivers/clk/sunxi/clk-sun9i-core.c index d93c7a53c6c0..70fbd7390d96 100644 --- a/drivers/clk/sunxi/clk-sun9i-core.c +++ b/drivers/clk/sunxi/clk-sun9i-core.c @@ -50,7 +50,7 @@ static void sun9i_a80_get_pll4_factors(struct factors_request *req) else if (n < 12) n = 12; - req->rate = ((24000000 * n) >> p) / (m + 1); + req->rate = ((24000000ULL * n) >> p) / (m + 1); req->n = n; req->m = m; req->p = p;