From: sashiko-bot@kernel.org
To: "Akari Tsuyukusa" <akkun11.open@gmail.com>
Cc: "open list:COMMON CLK FRAMEWORK" <linux-clk@vger.kernel.org>
Subject: Re: [PATCH v2 28/35] clk: mediatek: mt8173-infracfg: Switch to common probe/remove helpers
Date: Tue, 13 Oct 2026 17:01:00 +0000 [thread overview]
Message-ID: <sashiko-outbox-170182@kernel.org> (raw)
In-Reply-To: <20261013151734.3177690-29-akkun11.open@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] clk: mediatek: early timer initialization breaks due to removal of CLK_OF_DECLARE_DRIVER
- [High] clk: mediatek: out-of-bounds array write in mtk_clk_simple_probe due to sparse IDs
--
commit cabfa228cff0aa82afbc9489448b517cc6478e89
Author: Akari Tsuyukusa <akkun11.open@gmail.com>
clk: mediatek: mt8173-infracfg: Switch to common probe/remove helpers
The MT8173 infracfg driver previously needed custom probe/remove
callbacks to register and unregister cpumux. With cpumux support now
available in the common helpers, the driver can use
mtk_clk_simple_probe() and mtk_clk_simple_remove().
> diff --git a/drivers/clk/mediatek/clk-mt8173-infracfg.c b/drivers/clk/mediatek/clk-mt8173-infracfg.c
> index 9b8c358977891..fdd994736e833 100644
> --- a/drivers/clk/mediatek/clk-mt8173-infracfg.c
> +++ b/drivers/clk/mediatek/clk-mt8173-infracfg.c
[ ... ]
> @@ -70,95 +68,29 @@ static const struct mtk_clk_rst_desc clk_rst_desc = {
> .rst_bank_nr = ARRAY_SIZE(infrasys_rst_ofs),
> };
>
> +static const struct mtk_clk_desc infracfg_desc = {
> + .clks = infra_gates,
> + .num_clks = ARRAY_SIZE(infra_gates),
> + .factor_clks = infra_divs,
> + .num_factor_clks = ARRAY_SIZE(infra_divs),
> + .cpumuxes = cpu_muxes,
> + .num_cpumuxes = ARRAY_SIZE(cpu_muxes),
> + .rst_desc = &clk_rst_desc,
> +};
[Severity: High]
Does this code under-allocate the clock array by using the sum of element
counts rather than the maximum clock ID?
The transition to mtk_clk_simple_probe() calculates num_clks by summing the
array sizes in infracfg_desc (11 gates + 1 factor + 2 cpumuxes = 14 elements).
Consequently, mtk_alloc_clk_data(14) allocates exactly 14 elements.
However, mt8173-infracfg uses sparse IDs. For example, CLK_INFRA_CA72SEL is
defined as 14. When mtk_clk_register_cpumuxes() registers this cpumux, it
attempts to assign the clock pointer to clk_data->hws[14]:
drivers/clk/mediatek/clk-cpumux.c:mtk_clk_register_cpumuxes() {
...
clk_data->hws[mux->id] = hw;
...
}
This performs an out-of-bounds write past the end of the allocation. The
previous custom probe avoided this by explicitly allocating CLK_INFRA_NR_CLK
elements.
> static const struct of_device_id of_match_clk_mt8173_infracfg[] = {
> - { .compatible = "mediatek,mt8173-infracfg" },
> + { .compatible = "mediatek,mt8173-infracfg", .data = &infracfg_desc },
> { /* sentinel */ }
> };
> MODULE_DEVICE_TABLE(of, of_match_clk_mt8173_infracfg);
>
> -static void clk_mt8173_infra_init_early(struct device_node *node)
> -{
> - int i;
> -
> - infra_clk_data = mtk_alloc_clk_data(CLK_INFRA_NR_CLK);
> - if (!infra_clk_data)
> - return;
> -
> - for (i = 0; i < CLK_INFRA_NR_CLK; i++)
> - infra_clk_data->hws[i] = ERR_PTR(-EPROBE_DEFER);
> -
> - mtk_clk_register_factors(infra_early_divs,
> - ARRAY_SIZE(infra_early_divs), infra_clk_data);
> -
> - of_clk_add_hw_provider(node, of_clk_hw_onecell_get, infra_clk_data);
> -}
> -CLK_OF_DECLARE_DRIVER(mtk_infrasys, "mediatek,mt8173-infracfg",
> - clk_mt8173_infra_init_early);
[Severity: High]
Does removing CLK_OF_DECLARE_DRIVER break early timer initialization?
The MT8173 device tree defines a system timer matching mediatek,mt6577-timer,
which depends on CLK_INFRA_CLK_13M. This timer is initialized during early boot
via TIMER_OF_DECLARE running synchronously from timer_probe().
By removing CLK_OF_DECLARE_DRIVER from mt8173-infracfg, the infracfg clock
provider is deferred to the standard platform module probe phase. When
timer_probe() executes early in boot, of_clk_get() for CLK_INFRA_CLK_13M
returns -EPROBE_DEFER.
Since timer_probe() completely ignores deferred probing and never retries:
drivers/clocksource/timer-probe.c:timer_probe() {
...
ret = init_func_ret(np);
if (ret) {
if (ret != -EPROBE_DEFER)
pr_err("Failed to initialize '%pOF': %d\n", np, ret);
continue;
}
...
}
This causes the system to permanently lose its mt6577-timer (clocksource,
clockevents, and sched_clock), leading to a boot regression.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261013151734.3177690-1-akkun11.open@gmail.com?part=28
next prev parent reply other threads:[~2026-10-13 17:01 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-13 15:16 [PATCH v2 00/35] clk: mediatek: Migrate to common probe/remove helpers and fix memory leaks Akari Tsuyukusa
2026-10-13 15:17 ` [PATCH v2 01/35] clk: mediatek: mt2712: Fix memory leak on module removal Akari Tsuyukusa
2026-10-13 15:17 ` [PATCH v2 02/35] clk: mediatek: mt6795: " Akari Tsuyukusa
2026-10-13 15:36 ` sashiko-bot
2026-10-13 15:17 ` [PATCH v2 03/35] clk: mediatek: mt7622: " Akari Tsuyukusa
2026-10-13 15:34 ` sashiko-bot
2026-10-13 15:17 ` [PATCH v2 04/35] clk: mediatek: mt8135: " Akari Tsuyukusa
2026-10-13 15:17 ` [PATCH v2 05/35] clk: mediatek: mt8173: " Akari Tsuyukusa
2026-10-13 15:17 ` [PATCH v2 06/35] clk: mediatek: mt8192: " Akari Tsuyukusa
2026-10-13 15:17 ` [PATCH v2 07/35] clk: mediatek: mt6735: Add missing MODULE_DEVICE_TABLE() Akari Tsuyukusa
2026-10-13 15:17 ` [PATCH v2 08/35] clk: mediatek: mt7988-apmixed: " Akari Tsuyukusa
2026-10-13 15:17 ` [PATCH v2 09/35] clk: mediatek: Fix index in composite clock unwind path Akari Tsuyukusa
2026-10-13 15:49 ` sashiko-bot
2026-10-13 15:17 ` [PATCH v2 10/35] clk: mediatek: Fix memory leak in mtk_clk_register_gate() Akari Tsuyukusa
2026-10-13 15:17 ` [PATCH v2 11/35] clk: mediatek: return 0 instead of r in __mtk_clk_simple_probe() Akari Tsuyukusa
2026-10-13 15:17 ` [PATCH v2 12/35] clk: mediatek: Add cpumux support to common probe/remove helpers Akari Tsuyukusa
2026-10-13 15:17 ` [PATCH v2 13/35] clk: mediatek: Add PLL " Akari Tsuyukusa
2026-10-13 15:58 ` sashiko-bot
2026-10-13 15:17 ` [PATCH v2 14/35] clk: mediatek: Add child-device population to " Akari Tsuyukusa
2026-10-13 16:10 ` sashiko-bot
2026-10-13 15:17 ` [PATCH v2 15/35] clk: mediatek: Add FHCTL support to common " Akari Tsuyukusa
2026-10-13 16:09 ` sashiko-bot
2026-10-13 15:17 ` [PATCH v2 16/35] clk: mediatek: mt2701: Switch " Akari Tsuyukusa
2026-10-13 16:23 ` sashiko-bot
2026-10-13 15:17 ` [PATCH v2 17/35] clk: mediatek: mt2712-apmixedsys: " Akari Tsuyukusa
2026-10-13 16:20 ` sashiko-bot
2026-10-13 15:17 ` [PATCH v2 18/35] clk: mediatek: mt6735-apmixedsys: " Akari Tsuyukusa
2026-10-13 15:17 ` [PATCH v2 19/35] clk: mediatek: mt6779: " Akari Tsuyukusa
2026-10-13 16:31 ` sashiko-bot
2026-10-13 15:17 ` [PATCH v2 20/35] clk: mediatek: mt6795: " Akari Tsuyukusa
2026-10-13 15:17 ` [PATCH v2 21/35] clk: mediatek: mt6797: " Akari Tsuyukusa
2026-10-13 16:39 ` sashiko-bot
2026-10-13 15:17 ` [PATCH v2 22/35] clk: mediatek: mt7622: " Akari Tsuyukusa
2026-10-13 15:17 ` [PATCH v2 23/35] clk: mediatek: mt7981-apmixed: " Akari Tsuyukusa
2026-10-13 15:17 ` [PATCH v2 24/35] clk: mediatek: mt7986-apmixed: " Akari Tsuyukusa
2026-10-13 15:17 ` [PATCH v2 25/35] clk: mediatek: mt7988-apmixed: " Akari Tsuyukusa
2026-10-13 16:52 ` sashiko-bot
2026-10-13 15:17 ` [PATCH v2 26/35] clk: mediatek: mt8135-apmixedsys: " Akari Tsuyukusa
2026-10-13 16:50 ` sashiko-bot
2026-10-13 15:17 ` [PATCH v2 27/35] clk: mediatek: mt8167-apmixedsys: " Akari Tsuyukusa
2026-10-13 15:17 ` [PATCH v2 28/35] clk: mediatek: mt8173-infracfg: " Akari Tsuyukusa
2026-10-13 17:01 ` sashiko-bot [this message]
2026-10-13 15:17 ` [PATCH v2 29/35] clk: mediatek: mt8183: " Akari Tsuyukusa
2026-10-13 15:17 ` [PATCH v2 30/35] clk: mediatek: mt8186-apmixedsys: " Akari Tsuyukusa
2026-10-13 15:17 ` [PATCH v2 31/35] clk: mediatek: mt8188-apmixedsys: " Akari Tsuyukusa
2026-10-13 15:17 ` [PATCH v2 32/35] clk: mediatek: mt8192: " Akari Tsuyukusa
2026-10-13 15:17 ` [PATCH v2 33/35] clk: mediatek: mt8195: " Akari Tsuyukusa
2026-10-13 15:17 ` [PATCH v2 34/35] clk: mediatek: mt8196: " Akari Tsuyukusa
2026-10-13 17:24 ` sashiko-bot
2026-10-13 15:17 ` [PATCH v2 35/35] clk: mediatek: mt8516-apmixedsys: " Akari Tsuyukusa
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=sashiko-outbox-170182@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=akkun11.open@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox