Linux Hardening
 help / color / mirror / Atom feed
* [PATCH 00/11] clk: Set __counted_by counts before filling the arrays
@ 2026-12-04  0:15 Ben Cressey
  2026-12-04  0:15 ` [PATCH 01/11] clk: anlogic: Assign .num before accessing .hws Ben Cressey
                   ` (10 more replies)
  0 siblings, 11 replies; 23+ messages in thread
From: Ben Cressey @ 2026-12-04  0:15 UTC (permalink / raw)
  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, linux-clk, linux-riscv,
	llvm, linux-hardening, Harry Austen, Changhuang Liang, stable

Ten clk drivers access an array annotated with __counted_by while its
count is still zero. CONFIG_UBSAN_BOUNDS reports those accesses, and
CONFIG_UBSAN_TRAP can stop the boot or the probe on them. In v7.4-rc5,
this affects Clang 20 and 21, where CONFIG_CC_HAS_BROKEN_COUNTED_BY_REF
keeps the flex allocators from setting the count. Nine of the drivers
are also affected in older releases.

The bm1880 driver needs two patches, because its array is also one
element short. Patch 9 fixes the size, and patch 10 sets the count
earlier.

The Cadence Sierra PHY driver has the same late count, and its fix goes
to linux-phy. On next-20261202, patch 3 needs a three-way merge.

Functional tests ran under QEMU TCG on arm64, with RAM-backed registers
and with stubs for the lmk04832 SPI bus and the zynqmp firmware.
Mainline with Clang 20 and 21 drew reports before the series and none
after it. So did backports to v7.3 (GCC 15, Clang 22) and 6.18.y (GCC
15). The clps711x, mmp, sifive and jh7100 drivers ran outside their
platforms, and were also built for their own architectures. The sifive
driver also ran on QEMU's sifive_u. Not tested on hardware.

Code and text developed with LLM assistance.

---
Ben Cressey (11):
      clk: anlogic: Assign .num before accessing .hws
      clk: lmk04832: Assign .num before accessing .hws
      clk: mmp: audio: Assign .num before accessing .hws
      clk: sifive: prci: Assign .num before accessing .hws
      clk: visconti: Assign .num before accessing .hws
      clk: clocking-wizard: Assign .num before accessing .hws
      clk: clps711x: Assign .num before accessing .hws
      clk: starfive: jh7100: Assign .num_reg before accessing .reg
      clk: bm1880: Size .hws by the highest clock id
      clk: bm1880: Assign .num before accessing .hws
      clk: zynqmp: Assign .num before accessing .hws

 drivers/clk/anlogic/cru_dr1.c              |  4 ++--
 drivers/clk/clk-bm1880.c                   | 11 ++++-------
 drivers/clk/clk-clps711x.c                 |  2 +-
 drivers/clk/clk-lmk04832.c                 |  3 ++-
 drivers/clk/mmp/clk-audio.c                |  2 +-
 drivers/clk/sifive/sifive-prci.c           |  4 ++--
 drivers/clk/starfive/clk-starfive-jh7100.c |  1 +
 drivers/clk/visconti/clkc.c                |  2 +-
 drivers/clk/xilinx/clk-xlnx-clock-wizard.c |  2 +-
 drivers/clk/zynqmp/clkc.c                  |  2 +-
 10 files changed, 16 insertions(+), 17 deletions(-)
---
base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244
change-id: 20261203-clk-onecell-count-order-90a91cb82afb


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH 01/11] clk: anlogic: Assign .num before accessing .hws
  2026-12-04  0:15 [PATCH 00/11] clk: Set __counted_by counts before filling the arrays Ben Cressey
@ 2026-12-04  0:15 ` Ben Cressey
  2026-12-04 19:17   ` Justin Stitt
  2026-12-04  0:15 ` [PATCH 02/11] clk: lmk04832: " Ben Cressey
                   ` (9 subsequent siblings)
  10 siblings, 1 reply; 23+ messages in thread
From: Ben Cressey @ 2026-12-04  0:15 UTC (permalink / raw)
  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, linux-clk, linux-riscv,
	llvm, linux-hardening, Harry Austen, Changhuang Liang

hws[] is annotated with __counted_by(num), but dr1_cru_clk_register()
fills it before it sets num. With Clang 20 and 21, devm_kzalloc_flex()
leaves num at zero. CONFIG_UBSAN_BOUNDS then reports the accesses and
CONFIG_UBSAN_TRAP makes the first one trap during probe.

Set num right after the allocation.

Found by an LLM-assisted check of __counted_by users.

Fixes: c4e2f5e69ba4 ("clk: anlogic: add cru support for Anlogic DR1V90 SoC")
Signed-off-by: Ben Cressey <ben@cressey.dev>
---
 drivers/clk/anlogic/cru_dr1.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/anlogic/cru_dr1.c b/drivers/clk/anlogic/cru_dr1.c
index 478a52d5fa36c..b4ab385455e8b 100644
--- a/drivers/clk/anlogic/cru_dr1.c
+++ b/drivers/clk/anlogic/cru_dr1.c
@@ -187,6 +187,8 @@ int dr1_cru_clk_register(struct device *dev, void __iomem *base,
 	if (!priv)
 		return -ENOMEM;
 
+	priv->num = nr_clks;
+
 	for (i = 0; i < nr_clks; i++) {
 		const struct cru_clk *clk = &clks[i];
 
@@ -200,8 +202,6 @@ int dr1_cru_clk_register(struct device *dev, void __iomem *base,
 		priv->hws[i] = clk->hw;
 	}
 
-	priv->num = nr_clks;
-
 	ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, priv);
 	if (ret)
 		dev_err(dev, "failed to add clock hardware provider\n");

-- 
2.56.0


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 02/11] clk: lmk04832: Assign .num before accessing .hws
  2026-12-04  0:15 [PATCH 00/11] clk: Set __counted_by counts before filling the arrays Ben Cressey
  2026-12-04  0:15 ` [PATCH 01/11] clk: anlogic: Assign .num before accessing .hws Ben Cressey
@ 2026-12-04  0:15 ` Ben Cressey
  2026-12-04 19:21   ` Justin Stitt
  2026-12-04  0:15 ` [PATCH 03/11] clk: mmp: audio: " Ben Cressey
                   ` (8 subsequent siblings)
  10 siblings, 1 reply; 23+ messages in thread
From: Ben Cressey @ 2026-12-04  0:15 UTC (permalink / raw)
  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, linux-clk, linux-riscv,
	llvm, linux-hardening, Harry Austen, Changhuang Liang, stable

hws[] is annotated with __counted_by(num), but
lmk04832_register_clkout() fills it before lmk04832_probe() sets num.
The count is still zero with Clang 20 and 21, where devm_kzalloc_flex()
does not set it, and on v6.6 to v7.3, which use devm_kzalloc(). With
__counted_by enabled, CONFIG_UBSAN_BOUNDS reports the accesses and
CONFIG_UBSAN_TRAP makes the first one trap during probe.

Set num right after the allocation.

Found by an LLM-assisted check of __counted_by users.

Fixes: f316cdff8d67 ("clk: Annotate struct clk_hw_onecell_data with __counted_by")
Cc: stable@vger.kernel.org
Signed-off-by: Ben Cressey <ben@cressey.dev>
---
 drivers/clk/clk-lmk04832.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/clk-lmk04832.c b/drivers/clk/clk-lmk04832.c
index e6e771e8eb145..ad66cf097b9ba 100644
--- a/drivers/clk/clk-lmk04832.c
+++ b/drivers/clk/clk-lmk04832.c
@@ -1435,6 +1435,8 @@ static int lmk04832_probe(struct spi_device *spi)
 		return ret;
 	}
 
+	lmk->clk_data->num = info->num_channels;
+
 	device_property_read_u32(lmk->dev, "ti,vco-hz", &lmk->vco_rate);
 
 	lmk->sysref_ddly = 8;
@@ -1530,7 +1532,6 @@ static int lmk04832_probe(struct spi_device *spi)
 		}
 	}
 
-	lmk->clk_data->num = info->num_channels;
 	ret = devm_of_clk_add_hw_provider(lmk->dev, of_clk_hw_onecell_get,
 					  lmk->clk_data);
 	if (ret) {

-- 
2.56.0


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 03/11] clk: mmp: audio: Assign .num before accessing .hws
  2026-12-04  0:15 [PATCH 00/11] clk: Set __counted_by counts before filling the arrays Ben Cressey
  2026-12-04  0:15 ` [PATCH 01/11] clk: anlogic: Assign .num before accessing .hws Ben Cressey
  2026-12-04  0:15 ` [PATCH 02/11] clk: lmk04832: " Ben Cressey
@ 2026-12-04  0:15 ` Ben Cressey
  2026-12-04 19:24   ` Justin Stitt
  2026-12-04  0:15 ` [PATCH 04/11] clk: sifive: prci: " Ben Cressey
                   ` (7 subsequent siblings)
  10 siblings, 1 reply; 23+ messages in thread
From: Ben Cressey @ 2026-12-04  0:15 UTC (permalink / raw)
  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, linux-clk, linux-riscv,
	llvm, linux-hardening, Harry Austen, Changhuang Liang, stable

hws[] is annotated with __counted_by(num), but register_clocks() fills
it before it sets num. The count is still zero with Clang 20 and 21,
where devm_kzalloc_flex() does not set it, and on v6.6 to v7.3, which
use devm_kzalloc(). With __counted_by enabled, CONFIG_UBSAN_BOUNDS
reports the accesses and CONFIG_UBSAN_TRAP makes the first one trap
during probe.

Set num right after the allocation.

Found by an LLM-assisted check of __counted_by users.

Fixes: f316cdff8d67 ("clk: Annotate struct clk_hw_onecell_data with __counted_by")
Cc: stable@vger.kernel.org
Signed-off-by: Ben Cressey <ben@cressey.dev>
---
 drivers/clk/mmp/clk-audio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/mmp/clk-audio.c b/drivers/clk/mmp/clk-audio.c
index 19233684fbf9b..6b74aaed64b41 100644
--- a/drivers/clk/mmp/clk-audio.c
+++ b/drivers/clk/mmp/clk-audio.c
@@ -340,7 +340,6 @@ static int register_clocks(struct mmp2_audio_clk *priv, struct device *dev)
 	priv->clk_data.hws[MMP2_CLK_AUDIO_SYSCLK] = &priv->sysclk_gate.hw;
 	priv->clk_data.hws[MMP2_CLK_AUDIO_SSPA0] = &priv->sspa0_gate.hw;
 	priv->clk_data.hws[MMP2_CLK_AUDIO_SSPA1] = &priv->sspa1_gate.hw;
-	priv->clk_data.num = CLK_AUDIO_NR_CLKS;
 
 	return of_clk_add_hw_provider(dev->of_node, of_clk_hw_onecell_get,
 				      &priv->clk_data);
@@ -356,6 +355,7 @@ static int mmp2_audio_clk_probe(struct platform_device *pdev)
 	if (!priv)
 		return -ENOMEM;
 
+	priv->clk_data.num = CLK_AUDIO_NR_CLKS;
 	spin_lock_init(&priv->lock);
 	platform_set_drvdata(pdev, priv);
 

-- 
2.56.0


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 04/11] clk: sifive: prci: Assign .num before accessing .hws
  2026-12-04  0:15 [PATCH 00/11] clk: Set __counted_by counts before filling the arrays Ben Cressey
                   ` (2 preceding siblings ...)
  2026-12-04  0:15 ` [PATCH 03/11] clk: mmp: audio: " Ben Cressey
@ 2026-12-04  0:15 ` Ben Cressey
  2026-12-04 19:26   ` Justin Stitt
  2026-12-04  0:15 ` [PATCH 05/11] clk: visconti: " Ben Cressey
                   ` (6 subsequent siblings)
  10 siblings, 1 reply; 23+ messages in thread
From: Ben Cressey @ 2026-12-04  0:15 UTC (permalink / raw)
  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, linux-clk, linux-riscv,
	llvm, linux-hardening, Harry Austen, Changhuang Liang, stable

hws[] is annotated with __counted_by(num), but __prci_register_clocks()
fills it before it sets num. The count is still zero with Clang 20 and
21, where devm_kzalloc_flex() does not set it, and on v6.6 to v7.3,
which use devm_kzalloc(). With __counted_by enabled, CONFIG_UBSAN_BOUNDS
reports the accesses and CONFIG_UBSAN_TRAP makes the first one trap
during probe.

Set num right after the allocation.

Found by an LLM-assisted check of __counted_by users.

Fixes: f316cdff8d67 ("clk: Annotate struct clk_hw_onecell_data with __counted_by")
Cc: stable@vger.kernel.org
Signed-off-by: Ben Cressey <ben@cressey.dev>
---
 drivers/clk/sifive/sifive-prci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/sifive/sifive-prci.c b/drivers/clk/sifive/sifive-prci.c
index 402b905d010ed..b4544d024dd88 100644
--- a/drivers/clk/sifive/sifive-prci.c
+++ b/drivers/clk/sifive/sifive-prci.c
@@ -540,8 +540,6 @@ static int __prci_register_clocks(struct device *dev, struct __prci_data *pd,
 		pd->hw_clks.hws[i] = &pic->hw;
 	}
 
-	pd->hw_clks.num = i;
-
 	r = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get,
 					&pd->hw_clks);
 	if (r) {
@@ -571,6 +569,8 @@ static int sifive_prci_probe(struct platform_device *pdev)
 	if (!pd)
 		return -ENOMEM;
 
+	pd->hw_clks.num = desc->num_clks;
+
 	pd->va = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(pd->va))
 		return PTR_ERR(pd->va);

-- 
2.56.0


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 05/11] clk: visconti: Assign .num before accessing .hws
  2026-12-04  0:15 [PATCH 00/11] clk: Set __counted_by counts before filling the arrays Ben Cressey
                   ` (3 preceding siblings ...)
  2026-12-04  0:15 ` [PATCH 04/11] clk: sifive: prci: " Ben Cressey
@ 2026-12-04  0:15 ` Ben Cressey
  2026-12-04 19:29   ` Justin Stitt
  2026-12-04  0:15 ` [PATCH 06/11] clk: clocking-wizard: " Ben Cressey
                   ` (5 subsequent siblings)
  10 siblings, 1 reply; 23+ messages in thread
From: Ben Cressey @ 2026-12-04  0:15 UTC (permalink / raw)
  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, linux-clk, linux-riscv,
	llvm, linux-hardening, Harry Austen, Changhuang Liang, stable

hws[] is annotated with __counted_by(num), but visconti_init_clk() fills
it before it sets num. The count is still zero with Clang 20 and 21,
where devm_kzalloc_flex() does not set it, and on v6.6 to v7.3, which
use devm_kzalloc(). With __counted_by enabled, CONFIG_UBSAN_BOUNDS
reports the accesses and CONFIG_UBSAN_TRAP makes the first one trap
during probe.

Set num right after the allocation.

Found by an LLM-assisted check of __counted_by users.

Fixes: f316cdff8d67 ("clk: Annotate struct clk_hw_onecell_data with __counted_by")
Cc: stable@vger.kernel.org
Signed-off-by: Ben Cressey <ben@cressey.dev>
---
 drivers/clk/visconti/clkc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/visconti/clkc.c b/drivers/clk/visconti/clkc.c
index a75163b69751e..f8bb93d7027bc 100644
--- a/drivers/clk/visconti/clkc.c
+++ b/drivers/clk/visconti/clkc.c
@@ -195,9 +195,9 @@ struct visconti_clk_provider *visconti_init_clk(struct device *dev,
 	if (!ctx)
 		return ERR_PTR(-ENOMEM);
 
+	ctx->clk_data.num = nr_clks;
 	for (i = 0; i < nr_clks; ++i)
 		ctx->clk_data.hws[i] = ERR_PTR(-ENOENT);
-	ctx->clk_data.num = nr_clks;
 
 	ctx->dev = dev;
 	ctx->regmap = regmap;

-- 
2.56.0


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 06/11] clk: clocking-wizard: Assign .num before accessing .hws
  2026-12-04  0:15 [PATCH 00/11] clk: Set __counted_by counts before filling the arrays Ben Cressey
                   ` (4 preceding siblings ...)
  2026-12-04  0:15 ` [PATCH 05/11] clk: visconti: " Ben Cressey
@ 2026-12-04  0:15 ` Ben Cressey
  2026-12-04 19:29   ` Justin Stitt
  2026-12-04  0:15 ` [PATCH 07/11] clk: clps711x: " Ben Cressey
                   ` (4 subsequent siblings)
  10 siblings, 1 reply; 23+ messages in thread
From: Ben Cressey @ 2026-12-04  0:15 UTC (permalink / raw)
  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, linux-clk, linux-riscv,
	llvm, linux-hardening, Harry Austen, Changhuang Liang, stable

hws[] is annotated with __counted_by(num), but
clk_wzrd_register_output_clocks() fills it before clk_wzrd_probe() sets
num. The count is still zero with Clang 20 and 21, where
devm_kzalloc_flex() does not set it, and on v6.13 to v7.3, which use
devm_kzalloc(). With __counted_by enabled, CONFIG_UBSAN_BOUNDS reports
the accesses and CONFIG_UBSAN_TRAP makes the first one trap during
probe. Nodes with xlnx,static-config do not reach this code.

Set num right after the allocation.

Found by an LLM-assisted check of __counted_by users.

Fixes: bb487924b161 ("clk: clocking-wizard: use newer clk_hw API")
Cc: stable@vger.kernel.org
Signed-off-by: Ben Cressey <ben@cressey.dev>
---
 drivers/clk/xilinx/clk-xlnx-clock-wizard.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/xilinx/clk-xlnx-clock-wizard.c b/drivers/clk/xilinx/clk-xlnx-clock-wizard.c
index 9f8830b40122a..d1e9b11da2011 100644
--- a/drivers/clk/xilinx/clk-xlnx-clock-wizard.c
+++ b/drivers/clk/xilinx/clk-xlnx-clock-wizard.c
@@ -1302,6 +1302,7 @@ static int clk_wzrd_probe(struct platform_device *pdev)
 				     nr_outputs);
 	if (!clk_wzrd)
 		return -ENOMEM;
+	clk_wzrd->clk_data.num = nr_outputs;
 	platform_set_drvdata(pdev, clk_wzrd);
 
 	clk_wzrd->base = devm_platform_ioremap_resource(pdev, 0);
@@ -1337,7 +1338,6 @@ static int clk_wzrd_probe(struct platform_device *pdev)
 		if (ret)
 			return ret;
 
-		clk_wzrd->clk_data.num = nr_outputs;
 		ret = devm_of_clk_add_hw_provider(&pdev->dev, of_clk_hw_onecell_get,
 						  &clk_wzrd->clk_data);
 		if (ret) {

-- 
2.56.0


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 07/11] clk: clps711x: Assign .num before accessing .hws
  2026-12-04  0:15 [PATCH 00/11] clk: Set __counted_by counts before filling the arrays Ben Cressey
                   ` (5 preceding siblings ...)
  2026-12-04  0:15 ` [PATCH 06/11] clk: clocking-wizard: " Ben Cressey
@ 2026-12-04  0:15 ` Ben Cressey
  2026-12-04 19:30   ` Justin Stitt
  2026-12-04  0:15 ` [PATCH 08/11] clk: starfive: jh7100: Assign .num_reg before accessing .reg Ben Cressey
                   ` (3 subsequent siblings)
  10 siblings, 1 reply; 23+ messages in thread
From: Ben Cressey @ 2026-12-04  0:15 UTC (permalink / raw)
  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, linux-clk, linux-riscv,
	llvm, linux-hardening, Harry Austen, Changhuang Liang, stable

hws[] is annotated with __counted_by(num), but clps711x_clk_init_dt()
fills it before it sets num. The count is still zero with Clang 20 and
21, where kzalloc_flex() does not set it, and on v6.6 to v6.19, which
use kzalloc(). With __counted_by enabled, CONFIG_UBSAN_BOUNDS reports
the accesses and CONFIG_UBSAN_TRAP makes the first one trap during boot.

Set num right after the allocation.

Found by an LLM-assisted check of __counted_by users.

Fixes: f316cdff8d67 ("clk: Annotate struct clk_hw_onecell_data with __counted_by")
Cc: stable@vger.kernel.org
Signed-off-by: Ben Cressey <ben@cressey.dev>
---
 drivers/clk/clk-clps711x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/clk-clps711x.c b/drivers/clk/clk-clps711x.c
index 27a57a9b3cb34..e2185b3daac99 100644
--- a/drivers/clk/clk-clps711x.c
+++ b/drivers/clk/clk-clps711x.c
@@ -57,6 +57,7 @@ static void __init clps711x_clk_init_dt(struct device_node *np)
 				    CLPS711X_CLK_MAX);
 	BUG_ON(!clps711x_clk);
 
+	clps711x_clk->clk_data.num = CLPS711X_CLK_MAX;
 	spin_lock_init(&clps711x_clk->lock);
 
 	/* Read PLL multiplier value and sanity check */
@@ -139,7 +140,6 @@ static void __init clps711x_clk_init_dt(struct device_node *np)
 			pr_err("clk %i: register failed with %ld\n",
 			       tmp, PTR_ERR(clps711x_clk->clk_data.hws[tmp]));
 
-	clps711x_clk->clk_data.num = CLPS711X_CLK_MAX;
 	of_clk_add_hw_provider(np, of_clk_hw_onecell_get,
 			       &clps711x_clk->clk_data);
 }

-- 
2.56.0


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 08/11] clk: starfive: jh7100: Assign .num_reg before accessing .reg
  2026-12-04  0:15 [PATCH 00/11] clk: Set __counted_by counts before filling the arrays Ben Cressey
                   ` (6 preceding siblings ...)
  2026-12-04  0:15 ` [PATCH 07/11] clk: clps711x: " Ben Cressey
@ 2026-12-04  0:15 ` Ben Cressey
  2026-12-04 19:31   ` Justin Stitt
  2026-12-04  0:15 ` [PATCH 09/11] clk: bm1880: Size .hws by the highest clock id Ben Cressey
                   ` (2 subsequent siblings)
  10 siblings, 1 reply; 23+ messages in thread
From: Ben Cressey @ 2026-12-04  0:15 UTC (permalink / raw)
  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, linux-clk, linux-riscv,
	llvm, linux-hardening, Harry Austen, Changhuang Liang, stable

reg[] is annotated with __counted_by(num_reg), but
clk_starfive_jh7100_probe() does not set num_reg. The count stays zero
with Clang 20 and 21, where devm_kzalloc_flex() does not set it, and on
v6.14 to v7.3, which use devm_kzalloc(). With __counted_by enabled,
CONFIG_UBSAN_BOUNDS reports the accesses and CONFIG_UBSAN_TRAP makes the
probe trap.

Set num_reg as the other jh71x0 drivers do.

Found by an LLM-assisted check of __counted_by users.

Fixes: 838c0a41d7ed ("clk: starfive: Make _clk_get become a common helper function")
Cc: <stable@vger.kernel.org> # 6.14.x
Signed-off-by: Ben Cressey <ben@cressey.dev>
---
 drivers/clk/starfive/clk-starfive-jh7100.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/clk/starfive/clk-starfive-jh7100.c b/drivers/clk/starfive/clk-starfive-jh7100.c
index 079da88ec66cf..c16343a41b21c 100644
--- a/drivers/clk/starfive/clk-starfive-jh7100.c
+++ b/drivers/clk/starfive/clk-starfive-jh7100.c
@@ -291,6 +291,7 @@ static int __init clk_starfive_jh7100_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	spin_lock_init(&priv->rmw_lock);
+	priv->num_reg = JH7100_CLK_PLL0_OUT;
 	priv->dev = &pdev->dev;
 	priv->base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(priv->base))

-- 
2.56.0


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 09/11] clk: bm1880: Size .hws by the highest clock id
  2026-12-04  0:15 [PATCH 00/11] clk: Set __counted_by counts before filling the arrays Ben Cressey
                   ` (7 preceding siblings ...)
  2026-12-04  0:15 ` [PATCH 08/11] clk: starfive: jh7100: Assign .num_reg before accessing .reg Ben Cressey
@ 2026-12-04  0:15 ` Ben Cressey
  2026-12-04 19:38   ` Justin Stitt
  2026-12-04  0:15 ` [PATCH 10/11] clk: bm1880: Assign .num before accessing .hws Ben Cressey
  2026-12-04  0:15 ` [PATCH 11/11] clk: zynqmp: " Ben Cressey
  10 siblings, 1 reply; 23+ messages in thread
From: Ben Cressey @ 2026-12-04  0:15 UTC (permalink / raw)
  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, linux-clk, linux-riscv,
	llvm, linux-hardening, Harry Austen, Changhuang Liang, stable

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 <ben@cressey.dev>
---
 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


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 10/11] clk: bm1880: Assign .num before accessing .hws
  2026-12-04  0:15 [PATCH 00/11] clk: Set __counted_by counts before filling the arrays Ben Cressey
                   ` (8 preceding siblings ...)
  2026-12-04  0:15 ` [PATCH 09/11] clk: bm1880: Size .hws by the highest clock id Ben Cressey
@ 2026-12-04  0:15 ` Ben Cressey
  2026-12-04 19:39   ` Justin Stitt
  2026-12-04  0:15 ` [PATCH 11/11] clk: zynqmp: " Ben Cressey
  10 siblings, 1 reply; 23+ messages in thread
From: Ben Cressey @ 2026-12-04  0:15 UTC (permalink / raw)
  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, linux-clk, linux-riscv,
	llvm, linux-hardening, Harry Austen, Changhuang Liang, stable

hws[] is annotated with __counted_by(num), but bm1880_clk_probe() fills
it before it sets num. The count is still zero with Clang 20 and 21,
where devm_kzalloc_flex() does not set it, and on v6.6 to v7.3, which
use devm_kzalloc(). With __counted_by enabled, CONFIG_UBSAN_BOUNDS
reports the accesses and CONFIG_UBSAN_TRAP makes the first one trap
during probe.

Set num before the loop that fills hws[].

Found by an LLM-assisted check of __counted_by users.

Fixes: f316cdff8d67 ("clk: Annotate struct clk_hw_onecell_data with __counted_by")
Cc: stable@vger.kernel.org
Signed-off-by: Ben Cressey <ben@cressey.dev>
---
 drivers/clk/clk-bm1880.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/clk/clk-bm1880.c b/drivers/clk/clk-bm1880.c
index dc13d90bdd919..e2511991eeea2 100644
--- a/drivers/clk/clk-bm1880.c
+++ b/drivers/clk/clk-bm1880.c
@@ -893,12 +893,11 @@ static int bm1880_clk_probe(struct platform_device *pdev)
 
 	clk_data->pll_base = pll_base;
 	clk_data->sys_base = sys_base;
+	clk_data->hw_data.num = num_clks;
 
 	for (i = 0; i < num_clks; i++)
 		clk_data->hw_data.hws[i] = ERR_PTR(-ENOENT);
 
-	clk_data->hw_data.num = num_clks;
-
 	bm1880_clk_register_plls(bm1880_pll_clks,
 				 ARRAY_SIZE(bm1880_pll_clks),
 				 clk_data);

-- 
2.56.0


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 11/11] clk: zynqmp: Assign .num before accessing .hws
  2026-12-04  0:15 [PATCH 00/11] clk: Set __counted_by counts before filling the arrays Ben Cressey
                   ` (9 preceding siblings ...)
  2026-12-04  0:15 ` [PATCH 10/11] clk: bm1880: Assign .num before accessing .hws Ben Cressey
@ 2026-12-04  0:15 ` Ben Cressey
  2026-12-04 19:40   ` Justin Stitt
  10 siblings, 1 reply; 23+ messages in thread
From: Ben Cressey @ 2026-12-04  0:15 UTC (permalink / raw)
  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, linux-clk, linux-riscv,
	llvm, linux-hardening, Harry Austen, Changhuang Liang, stable

hws[] is annotated with __counted_by(num), but zynqmp_register_clocks()
fills it before zynqmp_clk_setup() sets num. The count is still zero
with Clang 20 and 21, where kzalloc_flex() does not set it, and on v6.6
to v6.19, which use kzalloc(). With __counted_by enabled,
CONFIG_UBSAN_BOUNDS reports the accesses and CONFIG_UBSAN_TRAP makes the
first one trap during probe.

Set num right after the allocation.

Found by an LLM-assisted check of __counted_by users.

Fixes: f316cdff8d67 ("clk: Annotate struct clk_hw_onecell_data with __counted_by")
Cc: stable@vger.kernel.org
Signed-off-by: Ben Cressey <ben@cressey.dev>
---
 drivers/clk/zynqmp/clkc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/zynqmp/clkc.c b/drivers/clk/zynqmp/clkc.c
index d62f1901d0ab5..88d1281c284b8 100644
--- a/drivers/clk/zynqmp/clkc.c
+++ b/drivers/clk/zynqmp/clkc.c
@@ -762,6 +762,7 @@ static int zynqmp_clk_setup(struct device_node *np)
 	zynqmp_data = kzalloc_flex(*zynqmp_data, hws, clock_max_idx);
 	if (!zynqmp_data)
 		return -ENOMEM;
+	zynqmp_data->num = clock_max_idx;
 
 	clock = kzalloc_objs(*clock, clock_max_idx);
 	if (!clock) {
@@ -772,7 +773,6 @@ static int zynqmp_clk_setup(struct device_node *np)
 	zynqmp_get_clock_info();
 	zynqmp_register_clocks(np);
 
-	zynqmp_data->num = clock_max_idx;
 	return of_clk_add_hw_provider(np, of_clk_hw_onecell_get, zynqmp_data);
 }
 

-- 
2.56.0


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: [PATCH 01/11] clk: anlogic: Assign .num before accessing .hws
  2026-12-04  0:15 ` [PATCH 01/11] clk: anlogic: Assign .num before accessing .hws Ben Cressey
@ 2026-12-04 19:17   ` Justin Stitt
  0 siblings, 0 replies; 23+ messages in thread
From: Justin Stitt @ 2026-12-04 19:17 UTC (permalink / raw)
  To: Ben Cressey
  Cc: 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, Nick Desaulniers, Bill Wendling,
	Gustavo A. R. Silva, linux-arm-kernel, linux-clk, linux-riscv,
	llvm, linux-hardening, Harry Austen, Changhuang Liang

Hi,

On Thu, Dec 03, 2026 at 04:15:39PM -0800, Ben Cressey wrote:
> hws[] is annotated with __counted_by(num), but dr1_cru_clk_register()
> fills it before it sets num. With Clang 20 and 21, devm_kzalloc_flex()
> leaves num at zero. CONFIG_UBSAN_BOUNDS then reports the accesses and
> CONFIG_UBSAN_TRAP makes the first one trap during probe.
> 
> Set num right after the allocation.
> 
> Found by an LLM-assisted check of __counted_by users.
> 
> Fixes: c4e2f5e69ba4 ("clk: anlogic: add cru support for Anlogic DR1V90 SoC")
> Signed-off-by: Ben Cressey <ben@cressey.dev>
> ---
>  drivers/clk/anlogic/cru_dr1.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/clk/anlogic/cru_dr1.c b/drivers/clk/anlogic/cru_dr1.c
> index 478a52d5fa36c..b4ab385455e8b 100644
> --- a/drivers/clk/anlogic/cru_dr1.c
> +++ b/drivers/clk/anlogic/cru_dr1.c
> @@ -187,6 +187,8 @@ int dr1_cru_clk_register(struct device *dev, void __iomem *base,
>  	if (!priv)
>  		return -ENOMEM;
>  
> +	priv->num = nr_clks;
> +
>  	for (i = 0; i < nr_clks; i++) {
>  		const struct cru_clk *clk = &clks[i];
>  
> @@ -200,8 +202,6 @@ int dr1_cru_clk_register(struct device *dev, void __iomem *base,
>  		priv->hws[i] = clk->hw;
>  	}
>  
> -	priv->num = nr_clks;
> -
>  	ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, priv);
>  	if (ret)
>  		dev_err(dev, "failed to add clock hardware provider\n");
> 
> -- 
> 2.56.0
> 


Reviewed-by: Justin Stitt <justinstitt@google.com>

Justin

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 02/11] clk: lmk04832: Assign .num before accessing .hws
  2026-12-04  0:15 ` [PATCH 02/11] clk: lmk04832: " Ben Cressey
@ 2026-12-04 19:21   ` Justin Stitt
  0 siblings, 0 replies; 23+ messages in thread
From: Justin Stitt @ 2026-12-04 19:21 UTC (permalink / raw)
  To: Ben Cressey
  Cc: 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, Nick Desaulniers, Bill Wendling,
	Gustavo A. R. Silva, linux-arm-kernel, linux-clk, linux-riscv,
	llvm, linux-hardening, Harry Austen, Changhuang Liang, stable

Hi, 

On Thu, Dec 03, 2026 at 04:15:40PM -0800, Ben Cressey wrote:
> hws[] is annotated with __counted_by(num), but
> lmk04832_register_clkout() fills it before lmk04832_probe() sets num.
> The count is still zero with Clang 20 and 21, where devm_kzalloc_flex()
> does not set it, and on v6.6 to v7.3, which use devm_kzalloc(). With
> __counted_by enabled, CONFIG_UBSAN_BOUNDS reports the accesses and
> CONFIG_UBSAN_TRAP makes the first one trap during probe.
> 
> Set num right after the allocation.
> 
> Found by an LLM-assisted check of __counted_by users.
> 
> Fixes: f316cdff8d67 ("clk: Annotate struct clk_hw_onecell_data with __counted_by")
> Cc: stable@vger.kernel.org
> Signed-off-by: Ben Cressey <ben@cressey.dev>
> ---
>  drivers/clk/clk-lmk04832.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/clk/clk-lmk04832.c b/drivers/clk/clk-lmk04832.c
> index e6e771e8eb145..ad66cf097b9ba 100644
> --- a/drivers/clk/clk-lmk04832.c
> +++ b/drivers/clk/clk-lmk04832.c
> @@ -1435,6 +1435,8 @@ static int lmk04832_probe(struct spi_device *spi)
>  		return ret;
>  	}
>  
> +	lmk->clk_data->num = info->num_channels;
> +
>  	device_property_read_u32(lmk->dev, "ti,vco-hz", &lmk->vco_rate);
>  
>  	lmk->sysref_ddly = 8;
> @@ -1530,7 +1532,6 @@ static int lmk04832_probe(struct spi_device *spi)
>  		}
>  	}
>  
> -	lmk->clk_data->num = info->num_channels;
>  	ret = devm_of_clk_add_hw_provider(lmk->dev, of_clk_hw_onecell_get,
>  					  lmk->clk_data);
>  	if (ret) {
> 
> -- 
> 2.56.0
> 

Reviewed-by: Justin Stitt <justinstitt@google.com>

Justin

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 03/11] clk: mmp: audio: Assign .num before accessing .hws
  2026-12-04  0:15 ` [PATCH 03/11] clk: mmp: audio: " Ben Cressey
@ 2026-12-04 19:24   ` Justin Stitt
  0 siblings, 0 replies; 23+ messages in thread
From: Justin Stitt @ 2026-12-04 19:24 UTC (permalink / raw)
  To: Ben Cressey
  Cc: 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, Nick Desaulniers, Bill Wendling,
	Gustavo A. R. Silva, linux-arm-kernel, linux-clk, linux-riscv,
	llvm, linux-hardening, Harry Austen, Changhuang Liang, stable

Hi,

On Thu, Dec 03, 2026 at 04:15:41PM -0800, Ben Cressey wrote:
> hws[] is annotated with __counted_by(num), but register_clocks() fills
> it before it sets num. The count is still zero with Clang 20 and 21,
> where devm_kzalloc_flex() does not set it, and on v6.6 to v7.3, which
> use devm_kzalloc(). With __counted_by enabled, CONFIG_UBSAN_BOUNDS
> reports the accesses and CONFIG_UBSAN_TRAP makes the first one trap
> during probe.
> 
> Set num right after the allocation.
> 
> Found by an LLM-assisted check of __counted_by users.
> 
> Fixes: f316cdff8d67 ("clk: Annotate struct clk_hw_onecell_data with __counted_by")
> Cc: stable@vger.kernel.org
> Signed-off-by: Ben Cressey <ben@cressey.dev>
> ---
>  drivers/clk/mmp/clk-audio.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/clk/mmp/clk-audio.c b/drivers/clk/mmp/clk-audio.c
> index 19233684fbf9b..6b74aaed64b41 100644
> --- a/drivers/clk/mmp/clk-audio.c
> +++ b/drivers/clk/mmp/clk-audio.c
> @@ -340,7 +340,6 @@ static int register_clocks(struct mmp2_audio_clk *priv, struct device *dev)
>  	priv->clk_data.hws[MMP2_CLK_AUDIO_SYSCLK] = &priv->sysclk_gate.hw;
>  	priv->clk_data.hws[MMP2_CLK_AUDIO_SSPA0] = &priv->sspa0_gate.hw;
>  	priv->clk_data.hws[MMP2_CLK_AUDIO_SSPA1] = &priv->sspa1_gate.hw;
> -	priv->clk_data.num = CLK_AUDIO_NR_CLKS;
>  
>  	return of_clk_add_hw_provider(dev->of_node, of_clk_hw_onecell_get,
>  				      &priv->clk_data);
> @@ -356,6 +355,7 @@ static int mmp2_audio_clk_probe(struct platform_device *pdev)
>  	if (!priv)
>  		return -ENOMEM;
>  
> +	priv->clk_data.num = CLK_AUDIO_NR_CLKS;
>  	spin_lock_init(&priv->lock);
>  	platform_set_drvdata(pdev, priv);
>  
> 
> -- 
> 2.56.0
> 

Reviewed-by: Justin Stitt <justinstitt@google.com>

Justin

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 04/11] clk: sifive: prci: Assign .num before accessing .hws
  2026-12-04  0:15 ` [PATCH 04/11] clk: sifive: prci: " Ben Cressey
@ 2026-12-04 19:26   ` Justin Stitt
  0 siblings, 0 replies; 23+ messages in thread
From: Justin Stitt @ 2026-12-04 19:26 UTC (permalink / raw)
  To: Ben Cressey
  Cc: 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, Nick Desaulniers, Bill Wendling,
	Gustavo A. R. Silva, linux-arm-kernel, linux-clk, linux-riscv,
	llvm, linux-hardening, Harry Austen, Changhuang Liang, stable

Hi,

On Thu, Dec 03, 2026 at 04:15:42PM -0800, Ben Cressey wrote:
> hws[] is annotated with __counted_by(num), but __prci_register_clocks()
> fills it before it sets num. The count is still zero with Clang 20 and
> 21, where devm_kzalloc_flex() does not set it, and on v6.6 to v7.3,
> which use devm_kzalloc(). With __counted_by enabled, CONFIG_UBSAN_BOUNDS
> reports the accesses and CONFIG_UBSAN_TRAP makes the first one trap
> during probe.
> 
> Set num right after the allocation.
> 
> Found by an LLM-assisted check of __counted_by users.
> 
> Fixes: f316cdff8d67 ("clk: Annotate struct clk_hw_onecell_data with __counted_by")
> Cc: stable@vger.kernel.org
> Signed-off-by: Ben Cressey <ben@cressey.dev>
> ---
>  drivers/clk/sifive/sifive-prci.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/clk/sifive/sifive-prci.c b/drivers/clk/sifive/sifive-prci.c
> index 402b905d010ed..b4544d024dd88 100644
> --- a/drivers/clk/sifive/sifive-prci.c
> +++ b/drivers/clk/sifive/sifive-prci.c
> @@ -540,8 +540,6 @@ static int __prci_register_clocks(struct device *dev, struct __prci_data *pd,
>  		pd->hw_clks.hws[i] = &pic->hw;
>  	}
>  
> -	pd->hw_clks.num = i;
> -
>  	r = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get,
>  					&pd->hw_clks);
>  	if (r) {
> @@ -571,6 +569,8 @@ static int sifive_prci_probe(struct platform_device *pdev)
>  	if (!pd)
>  		return -ENOMEM;
>  
> +	pd->hw_clks.num = desc->num_clks;
> +
>  	pd->va = devm_platform_ioremap_resource(pdev, 0);
>  	if (IS_ERR(pd->va))
>  		return PTR_ERR(pd->va);
> 
> -- 
> 2.56.0
> 

Reviewed-by: Justin Stitt <justinstitt@google.com>

Justin

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 05/11] clk: visconti: Assign .num before accessing .hws
  2026-12-04  0:15 ` [PATCH 05/11] clk: visconti: " Ben Cressey
@ 2026-12-04 19:29   ` Justin Stitt
  0 siblings, 0 replies; 23+ messages in thread
From: Justin Stitt @ 2026-12-04 19:29 UTC (permalink / raw)
  To: Ben Cressey
  Cc: 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, Nick Desaulniers, Bill Wendling,
	Gustavo A. R. Silva, linux-arm-kernel, linux-clk, linux-riscv,
	llvm, linux-hardening, Harry Austen, Changhuang Liang, stable

Hi,

On Thu, Dec 03, 2026 at 04:15:43PM -0800, Ben Cressey wrote:
> hws[] is annotated with __counted_by(num), but visconti_init_clk() fills
> it before it sets num. The count is still zero with Clang 20 and 21,
> where devm_kzalloc_flex() does not set it, and on v6.6 to v7.3, which
> use devm_kzalloc(). With __counted_by enabled, CONFIG_UBSAN_BOUNDS
> reports the accesses and CONFIG_UBSAN_TRAP makes the first one trap
> during probe.
> 
> Set num right after the allocation.
> 
> Found by an LLM-assisted check of __counted_by users.
> 
> Fixes: f316cdff8d67 ("clk: Annotate struct clk_hw_onecell_data with __counted_by")
> Cc: stable@vger.kernel.org
> Signed-off-by: Ben Cressey <ben@cressey.dev>
> ---
>  drivers/clk/visconti/clkc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/clk/visconti/clkc.c b/drivers/clk/visconti/clkc.c
> index a75163b69751e..f8bb93d7027bc 100644
> --- a/drivers/clk/visconti/clkc.c
> +++ b/drivers/clk/visconti/clkc.c
> @@ -195,9 +195,9 @@ struct visconti_clk_provider *visconti_init_clk(struct device *dev,
>  	if (!ctx)
>  		return ERR_PTR(-ENOMEM);
>  
> +	ctx->clk_data.num = nr_clks;
>  	for (i = 0; i < nr_clks; ++i)
>  		ctx->clk_data.hws[i] = ERR_PTR(-ENOENT);
> -	ctx->clk_data.num = nr_clks;
>  
>  	ctx->dev = dev;
>  	ctx->regmap = regmap;
> 
> -- 
> 2.56.0
> 

Reviewed-by: Justin Stitt <justinstitt@google.com>

Justin

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 06/11] clk: clocking-wizard: Assign .num before accessing .hws
  2026-12-04  0:15 ` [PATCH 06/11] clk: clocking-wizard: " Ben Cressey
@ 2026-12-04 19:29   ` Justin Stitt
  0 siblings, 0 replies; 23+ messages in thread
From: Justin Stitt @ 2026-12-04 19:29 UTC (permalink / raw)
  To: Ben Cressey
  Cc: 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, Nick Desaulniers, Bill Wendling,
	Gustavo A. R. Silva, linux-arm-kernel, linux-clk, linux-riscv,
	llvm, linux-hardening, Harry Austen, Changhuang Liang, stable

Hi,

On Thu, Dec 03, 2026 at 04:15:44PM -0800, Ben Cressey wrote:
> hws[] is annotated with __counted_by(num), but
> clk_wzrd_register_output_clocks() fills it before clk_wzrd_probe() sets
> num. The count is still zero with Clang 20 and 21, where
> devm_kzalloc_flex() does not set it, and on v6.13 to v7.3, which use
> devm_kzalloc(). With __counted_by enabled, CONFIG_UBSAN_BOUNDS reports
> the accesses and CONFIG_UBSAN_TRAP makes the first one trap during
> probe. Nodes with xlnx,static-config do not reach this code.
> 
> Set num right after the allocation.
> 
> Found by an LLM-assisted check of __counted_by users.
> 
> Fixes: bb487924b161 ("clk: clocking-wizard: use newer clk_hw API")
> Cc: stable@vger.kernel.org
> Signed-off-by: Ben Cressey <ben@cressey.dev>
> ---
>  drivers/clk/xilinx/clk-xlnx-clock-wizard.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/clk/xilinx/clk-xlnx-clock-wizard.c b/drivers/clk/xilinx/clk-xlnx-clock-wizard.c
> index 9f8830b40122a..d1e9b11da2011 100644
> --- a/drivers/clk/xilinx/clk-xlnx-clock-wizard.c
> +++ b/drivers/clk/xilinx/clk-xlnx-clock-wizard.c
> @@ -1302,6 +1302,7 @@ static int clk_wzrd_probe(struct platform_device *pdev)
>  				     nr_outputs);
>  	if (!clk_wzrd)
>  		return -ENOMEM;
> +	clk_wzrd->clk_data.num = nr_outputs;
>  	platform_set_drvdata(pdev, clk_wzrd);
>  
>  	clk_wzrd->base = devm_platform_ioremap_resource(pdev, 0);
> @@ -1337,7 +1338,6 @@ static int clk_wzrd_probe(struct platform_device *pdev)
>  		if (ret)
>  			return ret;
>  
> -		clk_wzrd->clk_data.num = nr_outputs;
>  		ret = devm_of_clk_add_hw_provider(&pdev->dev, of_clk_hw_onecell_get,
>  						  &clk_wzrd->clk_data);
>  		if (ret) {
> 
> -- 
> 2.56.0
> 

Reviewed-by: Justin Stitt <justinstitt@google.com>

Justin

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 07/11] clk: clps711x: Assign .num before accessing .hws
  2026-12-04  0:15 ` [PATCH 07/11] clk: clps711x: " Ben Cressey
@ 2026-12-04 19:30   ` Justin Stitt
  0 siblings, 0 replies; 23+ messages in thread
From: Justin Stitt @ 2026-12-04 19:30 UTC (permalink / raw)
  To: Ben Cressey
  Cc: 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, Nick Desaulniers, Bill Wendling,
	Gustavo A. R. Silva, linux-arm-kernel, linux-clk, linux-riscv,
	llvm, linux-hardening, Harry Austen, Changhuang Liang, stable

Hi,

On Thu, Dec 03, 2026 at 04:15:45PM -0800, Ben Cressey wrote:
> hws[] is annotated with __counted_by(num), but clps711x_clk_init_dt()
> fills it before it sets num. The count is still zero with Clang 20 and
> 21, where kzalloc_flex() does not set it, and on v6.6 to v6.19, which
> use kzalloc(). With __counted_by enabled, CONFIG_UBSAN_BOUNDS reports
> the accesses and CONFIG_UBSAN_TRAP makes the first one trap during boot.
> 
> Set num right after the allocation.
> 
> Found by an LLM-assisted check of __counted_by users.
> 
> Fixes: f316cdff8d67 ("clk: Annotate struct clk_hw_onecell_data with __counted_by")
> Cc: stable@vger.kernel.org
> Signed-off-by: Ben Cressey <ben@cressey.dev>
> ---
>  drivers/clk/clk-clps711x.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/clk/clk-clps711x.c b/drivers/clk/clk-clps711x.c
> index 27a57a9b3cb34..e2185b3daac99 100644
> --- a/drivers/clk/clk-clps711x.c
> +++ b/drivers/clk/clk-clps711x.c
> @@ -57,6 +57,7 @@ static void __init clps711x_clk_init_dt(struct device_node *np)
>  				    CLPS711X_CLK_MAX);
>  	BUG_ON(!clps711x_clk);
>  
> +	clps711x_clk->clk_data.num = CLPS711X_CLK_MAX;
>  	spin_lock_init(&clps711x_clk->lock);
>  
>  	/* Read PLL multiplier value and sanity check */
> @@ -139,7 +140,6 @@ static void __init clps711x_clk_init_dt(struct device_node *np)
>  			pr_err("clk %i: register failed with %ld\n",
>  			       tmp, PTR_ERR(clps711x_clk->clk_data.hws[tmp]));
>  
> -	clps711x_clk->clk_data.num = CLPS711X_CLK_MAX;
>  	of_clk_add_hw_provider(np, of_clk_hw_onecell_get,
>  			       &clps711x_clk->clk_data);
>  }
> 
> -- 
> 2.56.0
>

Reviewed-by: Justin Stitt <justinstitt@google.com>kjA

Justin


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 08/11] clk: starfive: jh7100: Assign .num_reg before accessing .reg
  2026-12-04  0:15 ` [PATCH 08/11] clk: starfive: jh7100: Assign .num_reg before accessing .reg Ben Cressey
@ 2026-12-04 19:31   ` Justin Stitt
  0 siblings, 0 replies; 23+ messages in thread
From: Justin Stitt @ 2026-12-04 19:31 UTC (permalink / raw)
  To: Ben Cressey
  Cc: 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, Nick Desaulniers, Bill Wendling,
	Gustavo A. R. Silva, linux-arm-kernel, linux-clk, linux-riscv,
	llvm, linux-hardening, Harry Austen, Changhuang Liang, stable

Hi,

On Thu, Dec 03, 2026 at 04:15:46PM -0800, Ben Cressey wrote:
> reg[] is annotated with __counted_by(num_reg), but
> clk_starfive_jh7100_probe() does not set num_reg. The count stays zero
> with Clang 20 and 21, where devm_kzalloc_flex() does not set it, and on
> v6.14 to v7.3, which use devm_kzalloc(). With __counted_by enabled,
> CONFIG_UBSAN_BOUNDS reports the accesses and CONFIG_UBSAN_TRAP makes the
> probe trap.
> 
> Set num_reg as the other jh71x0 drivers do.
> 
> Found by an LLM-assisted check of __counted_by users.
> 
> Fixes: 838c0a41d7ed ("clk: starfive: Make _clk_get become a common helper function")
> Cc: <stable@vger.kernel.org> # 6.14.x
> Signed-off-by: Ben Cressey <ben@cressey.dev>
> ---
>  drivers/clk/starfive/clk-starfive-jh7100.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/clk/starfive/clk-starfive-jh7100.c b/drivers/clk/starfive/clk-starfive-jh7100.c
> index 079da88ec66cf..c16343a41b21c 100644
> --- a/drivers/clk/starfive/clk-starfive-jh7100.c
> +++ b/drivers/clk/starfive/clk-starfive-jh7100.c
> @@ -291,6 +291,7 @@ static int __init clk_starfive_jh7100_probe(struct platform_device *pdev)
>  		return -ENOMEM;
>  
>  	spin_lock_init(&priv->rmw_lock);
> +	priv->num_reg = JH7100_CLK_PLL0_OUT;
>  	priv->dev = &pdev->dev;
>  	priv->base = devm_platform_ioremap_resource(pdev, 0);
>  	if (IS_ERR(priv->base))
> 
> -- 
> 2.56.0
> 

Reviewed-by: Justin Stitt <justinstitt@google.com>

Justin

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 09/11] clk: bm1880: Size .hws by the highest clock id
  2026-12-04  0:15 ` [PATCH 09/11] clk: bm1880: Size .hws by the highest clock id Ben Cressey
@ 2026-12-04 19:38   ` Justin Stitt
  0 siblings, 0 replies; 23+ messages in thread
From: Justin Stitt @ 2026-12-04 19:38 UTC (permalink / raw)
  To: Ben Cressey
  Cc: 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, Nick Desaulniers, Bill Wendling,
	Gustavo A. R. Silva, linux-arm-kernel, linux-clk, linux-riscv,
	llvm, linux-hardening, Harry Austen, Changhuang Liang, stable

Hi,

On Thu, Dec 03, 2026 at 04:15:47PM -0800, Ben Cressey wrote:
> 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 <ben@cressey.dev>
> ---
>  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
> 

Reviewed-by: Justin Stitt <justinstitt@google.com>

Justin

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 10/11] clk: bm1880: Assign .num before accessing .hws
  2026-12-04  0:15 ` [PATCH 10/11] clk: bm1880: Assign .num before accessing .hws Ben Cressey
@ 2026-12-04 19:39   ` Justin Stitt
  0 siblings, 0 replies; 23+ messages in thread
From: Justin Stitt @ 2026-12-04 19:39 UTC (permalink / raw)
  To: Ben Cressey
  Cc: 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, Nick Desaulniers, Bill Wendling,
	Gustavo A. R. Silva, linux-arm-kernel, linux-clk, linux-riscv,
	llvm, linux-hardening, Harry Austen, Changhuang Liang, stable

Hi,

On Thu, Dec 03, 2026 at 04:15:48PM -0800, Ben Cressey wrote:
> hws[] is annotated with __counted_by(num), but bm1880_clk_probe() fills
> it before it sets num. The count is still zero with Clang 20 and 21,
> where devm_kzalloc_flex() does not set it, and on v6.6 to v7.3, which
> use devm_kzalloc(). With __counted_by enabled, CONFIG_UBSAN_BOUNDS
> reports the accesses and CONFIG_UBSAN_TRAP makes the first one trap
> during probe.
> 
> Set num before the loop that fills hws[].
> 
> Found by an LLM-assisted check of __counted_by users.
> 
> Fixes: f316cdff8d67 ("clk: Annotate struct clk_hw_onecell_data with __counted_by")
> Cc: stable@vger.kernel.org
> Signed-off-by: Ben Cressey <ben@cressey.dev>
> ---
>  drivers/clk/clk-bm1880.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/clk/clk-bm1880.c b/drivers/clk/clk-bm1880.c
> index dc13d90bdd919..e2511991eeea2 100644
> --- a/drivers/clk/clk-bm1880.c
> +++ b/drivers/clk/clk-bm1880.c
> @@ -893,12 +893,11 @@ static int bm1880_clk_probe(struct platform_device *pdev)
>  
>  	clk_data->pll_base = pll_base;
>  	clk_data->sys_base = sys_base;
> +	clk_data->hw_data.num = num_clks;
>  
>  	for (i = 0; i < num_clks; i++)
>  		clk_data->hw_data.hws[i] = ERR_PTR(-ENOENT);
>  
> -	clk_data->hw_data.num = num_clks;
> -
>  	bm1880_clk_register_plls(bm1880_pll_clks,
>  				 ARRAY_SIZE(bm1880_pll_clks),
>  				 clk_data);
> 
> -- 
> 2.56.0
> 

Reviewed-by: Justin Stitt <justinstitt@google.com>

Justin

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 11/11] clk: zynqmp: Assign .num before accessing .hws
  2026-12-04  0:15 ` [PATCH 11/11] clk: zynqmp: " Ben Cressey
@ 2026-12-04 19:40   ` Justin Stitt
  0 siblings, 0 replies; 23+ messages in thread
From: Justin Stitt @ 2026-12-04 19:40 UTC (permalink / raw)
  To: Ben Cressey
  Cc: 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, Nick Desaulniers, Bill Wendling,
	Gustavo A. R. Silva, linux-arm-kernel, linux-clk, linux-riscv,
	llvm, linux-hardening, Harry Austen, Changhuang Liang, stable

Hi,

On Thu, Dec 03, 2026 at 04:15:49PM -0800, Ben Cressey wrote:
> hws[] is annotated with __counted_by(num), but zynqmp_register_clocks()
> fills it before zynqmp_clk_setup() sets num. The count is still zero
> with Clang 20 and 21, where kzalloc_flex() does not set it, and on v6.6
> to v6.19, which use kzalloc(). With __counted_by enabled,
> CONFIG_UBSAN_BOUNDS reports the accesses and CONFIG_UBSAN_TRAP makes the
> first one trap during probe.
> 
> Set num right after the allocation.
> 
> Found by an LLM-assisted check of __counted_by users.
> 
> Fixes: f316cdff8d67 ("clk: Annotate struct clk_hw_onecell_data with __counted_by")
> Cc: stable@vger.kernel.org
> Signed-off-by: Ben Cressey <ben@cressey.dev>
> ---
>  drivers/clk/zynqmp/clkc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/clk/zynqmp/clkc.c b/drivers/clk/zynqmp/clkc.c
> index d62f1901d0ab5..88d1281c284b8 100644
> --- a/drivers/clk/zynqmp/clkc.c
> +++ b/drivers/clk/zynqmp/clkc.c
> @@ -762,6 +762,7 @@ static int zynqmp_clk_setup(struct device_node *np)
>  	zynqmp_data = kzalloc_flex(*zynqmp_data, hws, clock_max_idx);
>  	if (!zynqmp_data)
>  		return -ENOMEM;
> +	zynqmp_data->num = clock_max_idx;
>  
>  	clock = kzalloc_objs(*clock, clock_max_idx);
>  	if (!clock) {
> @@ -772,7 +773,6 @@ static int zynqmp_clk_setup(struct device_node *np)
>  	zynqmp_get_clock_info();
>  	zynqmp_register_clocks(np);
>  
> -	zynqmp_data->num = clock_max_idx;
>  	return of_clk_add_hw_provider(np, of_clk_hw_onecell_get, zynqmp_data);
>  }
>  
> 
> -- 
> 2.56.0
> 

Reviewed-by: Justin Stitt <justinstitt@google.com>

Justin

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2026-12-04 19:40 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04  0:15 [PATCH 00/11] clk: Set __counted_by counts before filling the arrays Ben Cressey
2026-12-04  0:15 ` [PATCH 01/11] clk: anlogic: Assign .num before accessing .hws Ben Cressey
2026-12-04 19:17   ` Justin Stitt
2026-12-04  0:15 ` [PATCH 02/11] clk: lmk04832: " Ben Cressey
2026-12-04 19:21   ` Justin Stitt
2026-12-04  0:15 ` [PATCH 03/11] clk: mmp: audio: " Ben Cressey
2026-12-04 19:24   ` Justin Stitt
2026-12-04  0:15 ` [PATCH 04/11] clk: sifive: prci: " Ben Cressey
2026-12-04 19:26   ` Justin Stitt
2026-12-04  0:15 ` [PATCH 05/11] clk: visconti: " Ben Cressey
2026-12-04 19:29   ` Justin Stitt
2026-12-04  0:15 ` [PATCH 06/11] clk: clocking-wizard: " Ben Cressey
2026-12-04 19:29   ` Justin Stitt
2026-12-04  0:15 ` [PATCH 07/11] clk: clps711x: " Ben Cressey
2026-12-04 19:30   ` Justin Stitt
2026-12-04  0:15 ` [PATCH 08/11] clk: starfive: jh7100: Assign .num_reg before accessing .reg Ben Cressey
2026-12-04 19:31   ` Justin Stitt
2026-12-04  0:15 ` [PATCH 09/11] clk: bm1880: Size .hws by the highest clock id Ben Cressey
2026-12-04 19:38   ` Justin Stitt
2026-12-04  0:15 ` [PATCH 10/11] clk: bm1880: Assign .num before accessing .hws Ben Cressey
2026-12-04 19:39   ` Justin Stitt
2026-12-04  0:15 ` [PATCH 11/11] clk: zynqmp: " Ben Cressey
2026-12-04 19:40   ` Justin Stitt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox