Thread (35 messages) flat view 35 messages, 6 authors, 25d ago

Re: [PATCH v5 07/12] clk: ambarella: add CV75 CCU driver

From: sashiko-bot@kernel.org
Date: 2026-08-18 10:46:07
Also in: linux-clk

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Casting away `const` to modify a `const`-qualified array member via `memcpy` invokes undefined behavior.
--
--- Patch [7]: [PATCH v5 07/12] clk: ambarella: add CV75 CCU driver ---
commit 477493a502606783178c884c88d17f74d16fc602
Author: Long Zhao [off-list ref]

clk: ambarella: add CV75 CCU driver

Add the Ambarella CV75 clock driver covering the core PLL and the UART0
/ AHB / APB clocks needed for early console bring-up.
quoted hunk ↗ jump to hunk
diff --git a/drivers/clk/ambarella/ccu-cv75.c b/drivers/clk/ambarella/ccu-cv75.c
index 0000000000000..d682da3cf28d3
--- /dev/null
+++ b/drivers/clk/ambarella/ccu-cv75.c
[ ... ]
+static struct clk_hw *amb_cv75_register_clk(struct device *dev,
+					    struct amb_ccu *ccu,
+					    const struct amb_cv75_clk_desc *desc,
+					    struct clk_hw *osc,
+					    struct clk_hw *dummy)
+{
+	struct amb_pll_desc pll_desc;
+	struct clk_hw *parent;
+
+	switch (desc->type) {
[ ... ]
+	case AMB_CV75_CLK_PLL:
+		parent = amb_cv75_get_parent(ccu, osc, dummy, desc->parent);
+		if (IS_ERR(parent))
+			return parent;
+
+		pll_desc.name = desc->name;
+		pll_desc.parent = parent;
+		memcpy((void *)pll_desc.reg_offset, desc->pll.reg_offset,
+		       sizeof(pll_desc.reg_offset));
[Severity: Low]
Is it safe to cast away the const qualifier here? 

The reg_offset array in struct amb_pll_desc is defined as const u32. Modifying
a const-qualified object through a non-const pointer like this results in
undefined behavior under C language rules.

Could this be refactored so that the struct initialization doesn't require
casting away const?
+		pll_desc.soc_data = desc->pll.soc_data;
+		pll_desc.frac_mode = false;
+
+		return amb_pll_register(dev, ccu->map, &pll_desc);
-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260818-cv75-v5-v5-0-7bbb12f0360f@ambarella.com?part=7
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help