[PATCH 08/11] clk: starfive: jh7100: Assign .num_reg before accessing .reg
Ben Cressey
ben at cressey.dev
Thu Dec 3 16:15:46 PST 2026
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 at vger.kernel.org> # 6.14.x
Signed-off-by: Ben Cressey <ben at 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
More information about the linux-arm-kernel
mailing list