Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.37 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796343472; b=G8h3hKEoA0vgIwM9kYNQL1s2PlSrtTWQzXpOWJR5fhWIj3lLzrd/0NgEEj0ujCmI5Dd/ CQ8pCWMCTj+4l2fm/ssLnKB9fuxC5ueGIBWVAp9PgSa3vtByLt3lY/tBxBhR7cO7+iPVk O2y6DyAKmmnlMx1+QRCn6Tu223AH68n3vd2qtTIV2WHrB0EMGae85bTI5JLphQc6O+V7o D4apVwBGSn12zHcOzs7abAQWMXK6kgh/QDR9B29YweXJCMaZlOx4LW3WOa0FrFib5zlZp SaMkTvXe/FNJB3witqayJmZ6pT/1mINYi4XoyE9nQEIpRuQJjlyttVTc1/KqNodYgSw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796343472; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:From:Subject:To:Cc:X-Mailer: MIME-Version:Content-Type:Content-Transfer-Encoding:Date:Message-Id: In-Reply-To:References; bh=132FS5E6iEMawz/6ohhOlE9lMisCCay1kw5GdueeePc=; b=rfSBBHvIO11ddqQJfRfkAQikJaHzvZ5i2hxuGJ5BcAAjAtqB8O0vD3oftaxK3sT9WuUx HDIJkCbJbwaUAeyXRwPDco4K5UR0iOy9ZSh6iggAvW5kAY0WFrx9uzMlNrt89uegWgkKM QVHSElIjhvYCzzHerzrHb+JgBFX1gJvVkydmtXDAliSZWpAOkxLX3Co1eA0gt2gf5O3QK +2o8K9KxC7wud2ms1VMkbfJdp7xXsNy3FsSAUDA8GVmaaw6nUWQHf4dL+86JGfnyljHJ9 3EsLS19lTTSMSxv02N0ACDZv59LzNL4dcU9tT9GW+yHiUpSqRcY12ZwWV5sYAikxVqQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=cressey.dev; spf=pass smtp.mailfrom=cressey.dev; dkim=pass header.d=cressey.dev header.i=@cressey.dev header.a=rsa-sha256 header.s=key1 header.b="FkgzVGo/"; arc=none smtp.remote-ip=95.215.58.37 Received: from mta1.migadu.com (out-37.mta1.migadu.com [95.215.58.37]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2EF2D606A32C for ; Fri, 4 Dec 2026 00:17:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2EF2D606A32C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cressey.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cressey.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=cressey.dev header.i=@cressey.dev header.a=rsa-sha256 header.s=key1 header.b=FkgzVGo/ X-Envelope-To: linux-clk@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=/pHEUlL2foNjNj9wgzBoEUFJPgxzMyMm8VoOIVSJ3rk=; c=simple/simple; d=cressey.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796343470; v=1; x=1796948270; b=FkgzVGo/CJP6KNEsZlkuhaIHpxVhW21tCnr7ywmbxEwmzDQcUR+njuDxK1oYMCu4yb9ToZpc 8bAyFe9TjZxwSkBgJ217Z1M048bEERZ6/aph85ZrnISiuwlI0TmH4mxnu2AZTjsr1DQcvqw09aC aRYCKeOC6BmDA4TxvlM86dzEYunTyxOkEH3hp2CmMNROsx2oUek7hOKyanEcslAo0UwZqsJQrvT BsxCY0kdQOeAPfhYtXnlOLpOA4DDcInTzZ0XGOZVfFXP/FOmXwSBcHrYoilLDQM+4fJQhjIfqwx iD5kQd9lnMtld9GDbiuL/EDw2GdSfnULZqcpY3qSADooA== X-Envelope-To: linux-clk@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id c68dabab95fe6c64; Fri, 04 Dec 2026 00:17:50 +0000 X-Mizu-Trace-ID: c68dabab95fe6c64 X-Migadu-Flow: FLOW_OUT From: Ben Cressey Subject: [PATCH 09/11] clk: bm1880: Size .hws by the highest clock id To: Junhui Liu , Manivannan Sadhasivam , Nobuhiro Iwamatsu , Michal Simek , Stephen Boyd , Brian Masney , Jerome Brunet , Paul Walmsley , Samuel Holland , Emil Renner Berthing , Hal Feng , Nathan Chancellor , Kees Cook Cc: Nick Desaulniers , Bill Wendling , Justin Stitt , "Gustavo A. R. Silva" , linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org, linux-riscv@lists.infradead.org, llvm@lists.linux.dev, linux-hardening@vger.kernel.org, Harry Austen , Changhuang Liang , stable@vger.kernel.org X-Mailer: b4 0.15.2 X-Mailing-List: linux-clk@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Date: Thu, 03 Dec 2026 16:15:47 -0800 Message-Id: <20261203-clk-onecell-count-order-v1-9-2b0e4e8d9ea6@cressey.dev> In-Reply-To: <20261203-clk-onecell-count-order-v1-0-2b0e4e8d9ea6@cressey.dev> References: <20261203-clk-onecell-count-order-v1-0-2b0e4e8d9ea6@cressey.dev> bm1880_clk_probe() sizes hws[] by the sum of the five clock tables, but the array is indexed by clock id. The sum is 68 while the ids in the tables run from 1 to 68. BM1880_CLK_AXI6 is stored one element past the end of hws[], which CONFIG_UBSAN_BOUNDS can report, and of_clk_hw_onecell_get() rejects its index. Size hws[] by the highest clock id plus one. Keep that count in the driver rather than use BM1880_NR_CLKS from the binding header, as in commit 26ec588063d9 ("clk: nuvoton: ma35d1: Keep the clock count in the driver"). Found by an LLM-assisted review of __counted_by users. Fixes: 1ab4601da55b ("clk: Add common clock driver for BM1880 SoC") Cc: stable@vger.kernel.org Signed-off-by: Ben Cressey --- drivers/clk/clk-bm1880.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/clk/clk-bm1880.c b/drivers/clk/clk-bm1880.c index da8ff672ee0f9..dc13d90bdd919 100644 --- a/drivers/clk/clk-bm1880.c +++ b/drivers/clk/clk-bm1880.c @@ -53,6 +53,8 @@ #define BM1880_CLK_DIV27 0xac #define BM1880_CLK_DIV28 0xb0 +#define BM1880_CLK_COUNT (BM1880_CLK_AXI6 + 1) + #define to_bm1880_pll_clk(_hw) container_of(_hw, struct bm1880_pll_hw_clock, hw) #define to_bm1880_div_clk(_hw) container_of(_hw, struct bm1880_div_hw_clock, hw) @@ -883,11 +885,7 @@ static int bm1880_clk_probe(struct platform_device *pdev) if (IS_ERR(sys_base)) return PTR_ERR(sys_base); - num_clks = ARRAY_SIZE(bm1880_pll_clks) + - ARRAY_SIZE(bm1880_div_clks) + - ARRAY_SIZE(bm1880_mux_clks) + - ARRAY_SIZE(bm1880_composite_clks) + - ARRAY_SIZE(bm1880_gate_clks); + num_clks = BM1880_CLK_COUNT; clk_data = devm_kzalloc_flex(dev, *clk_data, hw_data.hws, num_clks); if (!clk_data) -- 2.56.0