From: sashiko-bot@kernel.org
To: "Christian Marangi" <ansuelsmth@gmail.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v5 2/3] clk: en7523: generalize register clocks function
Date: Thu, 28 May 2026 19:29:32 +0000 [thread overview]
Message-ID: <20260528192932.DB81D1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260528190000.9164-3-ansuelsmth@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] The PCIe clock backing structure is allocated with `devm_kzalloc()` but registered with non-managed `clk_hw_register()`, leading to a UAF if probe fails.
--
commit 8b129b6c8b9f7c7f67a06021102b7f5673eead5f
Author: Christian Marangi <ansuelsmth@gmail.com>
clk: en7523: generalize register clocks function
This commit generalizes the clock registration logic used by the Airoha
EN7581 SoC to also support the AN7583 SoC. It updates the implementation
to register clocks defined in the new soc_data structures.
> diff --git a/drivers/clk/clk-en7523.c b/drivers/clk/clk-en7523.c
> index 1ab0e2eca5d32..087ff4568124f 100644
> --- a/drivers/clk/clk-en7523.c
> +++ b/drivers/clk/clk-en7523.c
[ ... ]
> @@ -711,12 +712,15 @@ static int en7523_clk_hw_init(struct platform_device *pdev,
> static void en7581_register_clocks(struct device *dev, struct clk_hw_onecell_data *clk_data,
> struct regmap *map, void __iomem *base)
> {
[Severity: High]
This isn't a bug introduced by this patch, but looking at
en7523_register_pcie_clk() which is called at the end of this function, it
appears the clock backing structure is allocated with devm_kzalloc() but
registered with the non-managed clk_hw_register().
If probe fails later, the driver core will automatically unwind devm resources
and free the structure. However, because the clock was not registered with
devm_clk_hw_register(), CCF is never notified to unregister the clock and
retains dangling pointers to it.
Could this lead to a use-after-free if the CCF is subsequently accessed, for
example by reading clk_summary? Should en7523_register_pcie_clk() be updated
to use devm_clk_hw_register() instead?
> + const struct en_clk_soc_data *soc_data;
> struct clk_hw *hw;
> u32 rate;
> int i;
>
> - for (i = 0; i < ARRAY_SIZE(en7581_base_clks); i++) {
> - const struct en_clk_desc *desc = &en7581_base_clks[i];
> + soc_data = device_get_match_data(dev);
> +
> + for (i = 0; i < soc_data->num_clocks - 1; i++) {
> + const struct en_clk_desc *desc = &soc_data->base_clks[i];
> u32 val, reg = desc->div_reg ? desc->div_reg : desc->base_reg;
> int err;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260528190000.9164-1-ansuelsmth@gmail.com?part=2
next prev parent reply other threads:[~2026-05-28 19:29 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-28 18:59 [PATCH v5 0/3] clk: add support for Airoha AN7583 clock Christian Marangi
2026-05-28 18:59 ` [PATCH v5 1/3] dt-bindings: clock: airoha: Document support for " Christian Marangi
2026-05-28 19:10 ` sashiko-bot
2026-05-28 18:59 ` [PATCH v5 2/3] clk: en7523: generalize register clocks function Christian Marangi
2026-05-28 19:29 ` sashiko-bot [this message]
2026-05-28 18:59 ` [PATCH v5 3/3] clk: en7523: add support for Airoha AN7583 clock Christian Marangi
2026-05-28 20:10 ` sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260528192932.DB81D1F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=ansuelsmth@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox