[PATCH 00/11] clk: Set __counted_by counts before filling the arrays

Ben Cressey ben at cressey.dev
Thu Dec 3 16:15:38 PST 2026


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




More information about the linux-arm-kernel mailing list