From: sashiko-bot@kernel.org
To: "Benoît Monin" <benoit.monin@bootlin.com>
Cc: linux-clk@vger.kernel.org
Subject: Re: [PATCH v2 1/2] clk: eyeq: Use devm_platform_ioremap_resource()
Date: Mon, 14 Sep 2026 12:30:28 +0000 [thread overview]
Message-ID: <20260914123029.4D2041F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260914-clk-eyeq-res-v2-1-687e5de3aba7@bootlin.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Switching to devm_platform_ioremap_resource causes the MMIO region to be unmapped on probe failure, leaving dangling pointers in registered clocks.
--
commit d16beda6863fd4b206a647746c109b76b72334fa
Author: Benoît Monin <benoit.monin@bootlin.com>
clk: eyeq: Use devm_platform_ioremap_resource()
Convert eqc_probe() from the open-coded platform_get_resource() +
ioremap() sequence to devm_platform_ioremap_resource(). Besides less
code, this requests the memory region so the OLB registers are properly
reserved in the iomem_resource tree.
Move devm_platform_ioremap_resource() before checking for device match
data, so OLBs bound without match data also get their memory region
mapped and reserved.
> diff --git a/drivers/clk/clk-eyeq.c b/drivers/clk/clk-eyeq.c
> index cf37feccc734f..3662e6990bf7f 100644
> --- a/drivers/clk/clk-eyeq.c
> +++ b/drivers/clk/clk-eyeq.c
> @@ -513,21 +513,16 @@ static int eqc_probe(struct platform_device *pdev)
> const struct eqc_match_data *data;
> struct clk_hw_onecell_data *cells;
> unsigned int i, clk_count;
> - struct resource *res;
> void __iomem *base;
> int ret;
>
> + base = devm_platform_ioremap_resource(pdev, 0);
> + if (IS_ERR(base))
> + return PTR_ERR(base);
> +
[Severity: High]
Does this change introduce a regression if of_clk_add_hw_provider() fails
later in eqc_probe()?
If the provider registration fails, the probe function aborts and triggers
devres cleanup, which unmaps this base memory region.
However, the clocks are registered earlier in eqc_probe() using non-devm
functions:
drivers/clk/clk-eyeq.c:eqc_probe() {
...
for (i = 0; i < data->clk_count; i++) {
...
ret = clk->probe(dev, NULL, clk, base, cells);
...
}
return of_clk_add_hw_provider(np, of_clk_hw_onecell_get, cells);
}
drivers/clk/clk-eyeq.c:eqc_probe_divider() {
...
hw = clk_hw_register_divider_table_parent_data(dev, ...,
base + clk->div.reg, ...);
...
}
Because the clocks are registered with non-devm functions, they remain in
the clock framework on probe failure. Since base is now managed by devres,
the clock framework will hold dangling pointers to the unmapped base memory.
Prior to this change, the manual ioremap() was not unmapped on failure,
which avoided a use-after-free.
Would it be safer to convert the clock registrations to their devm
equivalents, or explicitly unregister them on probe failure to prevent
these dangling pointers?
> data = device_get_match_data(dev);
> if (!data)
> - return 0; /* No clocks nor auxdevs, we are done. */
> -
> - res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> - if (!res)
> - return -ENODEV;
> -
> - base = ioremap(res->start, resource_size(res));
> - if (!base)
> - return -ENOMEM;
> + return 0; /* No clocks nor auxdevs, stop here but keep resource reserved */
>
> /* Init optional auxiliary devices. */
> eqc_auxdev_create_optional(dev, base, data->reset_auxdev_name);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260914-clk-eyeq-res-v2-0-687e5de3aba7@bootlin.com?part=1
next prev parent reply other threads:[~2026-09-14 12:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-14 12:16 [PATCH v2 0/2] clk: eyeq: Reserve OLB memory regions Benoît Monin
2026-09-14 12:16 ` [PATCH v2 1/2] clk: eyeq: Use devm_platform_ioremap_resource() Benoît Monin
2026-09-14 12:30 ` sashiko-bot [this message]
2026-09-14 16:57 ` Brian Masney
2026-09-14 12:16 ` [PATCH v2 2/2] clk: eyeq: Add mobileye,eyeq6h-central-olb compatible Benoît Monin
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=20260914123029.4D2041F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=benoit.monin@bootlin.com \
--cc=linux-clk@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.