Re: [PATCH v5 07/12] clk: ambarella: add CV75 CCU driver
| Newsgroups | dev.linux.lists.mfd,org.kernel.vger.linux-clk,org.kernel.vger.linux-devicetree |
|---|---|
| Message-ID | <[email protected]> |
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 <[email protected]> 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. > 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/[email protected]?part=7