All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Louis-Alexis Eyraud" <louisalexis.eyraud@collabora.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v2 15/18] clk: mediatek: Add MT8189 dvfsrc clock support
Date: Fri, 10 Jul 2026 15:09:10 +0000	[thread overview]
Message-ID: <20260710150910.B0FAC1F0155D@smtp.kernel.org> (raw)
In-Reply-To: <20260709-mt8189-clocks-system-base-v2-15-2926da3db6cf@collabora.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Use-after-free in `__mtk_clk_simple_probe` error path due to missing `of_clk_del_provider()`.
--

--- Patch [15]: [PATCH v2 15/18] clk: mediatek: Add MT8189 dvfsrc clock support ---
commit 5ea7dacd6f8e27b2d8c56bae31053477a67a2318
Author: Louis-Alexis Eyraud <louisalexis.eyraud@collabora.com>

clk: mediatek: Add MT8189 dvfsrc clock support
    
This patch adds support for the MT8189 dvfsrc clock controller. This controller
provides clock gate control for DRAM DVFS.

> diff --git a/drivers/clk/mediatek/clk-mt8189-dvfsrc.c b/drivers/clk/mediatek/clk-mt8189-dvfsrc.c
> new file mode 100644
> index 0000000000000..37b81dc0b8824
> --- /dev/null
> +++ b/drivers/clk/mediatek/clk-mt8189-dvfsrc.c

[ ... ]

> +static struct platform_driver clk_mt8189_dvfsrc_drv = {
> +	.probe = mtk_clk_simple_probe,

[Severity: High]
This is a pre-existing issue, but does the error path in
__mtk_clk_simple_probe() leave a dangling pointer?

When mtk_clk_simple_probe() is called, it wraps __mtk_clk_simple_probe(). If
the clock provider is successfully added, but resetting the controller fails:

drivers/clk/mediatek/clk-mtk.c:__mtk_clk_simple_probe() {
...
	r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
	if (r)
		goto unregister_clks;

	platform_set_drvdata(pdev, clk_data);

	if (mcd->rst_desc) {
		r = mtk_register_reset_controller_with_dev(&pdev->dev,
							   mcd->rst_desc);
		if (r)
			goto unregister_clks;
	}
...

It jumps to unregister_clks which eventually frees the clk_data:

unregister_clks:
...
free_data:
	mtk_free_clk_data(clk_data);
...
}

Since of_clk_del_provider() is never called in this error path, doesn't this
leave a freed clk_data pointer in the global of_clk_providers list, leading
to a use-after-free on the next clock lookup?

> +	.remove = mtk_clk_simple_remove,
> +	.driver = {
> +		.name = "clk-mt8189-dvfsrc",
> +		.of_match_table = of_match_clk_mt8189_dvfsrc,
> +	},
> +};
> +module_platform_driver(clk_mt8189_dvfsrc_drv);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260709-mt8189-clocks-system-base-v2-0-2926da3db6cf@collabora.com?part=15

  reply	other threads:[~2026-07-10 15:09 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-09 13:42 [PATCH v2 00/18] MT8189: Add support for system and base clock controllers Louis-Alexis Eyraud
2026-07-09 13:42 ` [PATCH v2 01/18] dt-bindings: clock: mediatek: Make '#clock-cells' required for MT8186 Louis-Alexis Eyraud
2026-07-09 14:01   ` AngeloGioacchino Del Regno
2026-07-09 18:08     ` Conor Dooley
2026-07-09 13:42 ` [PATCH v2 02/18] dt-bindings: clock: mediatek: Make '#clock-cells' required for MT8192 Louis-Alexis Eyraud
2026-07-09 14:01   ` AngeloGioacchino Del Regno
2026-07-09 18:08     ` Conor Dooley
2026-07-09 13:42 ` [PATCH v2 03/18] dt-bindings: clock: mediatek: Make '#clock-cells' required for MT8195 Louis-Alexis Eyraud
2026-07-09 14:01   ` AngeloGioacchino Del Regno
2026-07-09 18:09   ` Conor Dooley
2026-07-10 15:09   ` sashiko-bot
2026-07-09 13:42 ` [PATCH v2 04/18] dt-bindings: clock: mediatek: reorder MT8186 compatibles Louis-Alexis Eyraud
2026-07-09 14:03   ` AngeloGioacchino Del Regno
2026-07-09 18:09   ` Conor Dooley
2026-07-09 13:42 ` [PATCH v2 05/18] dt-bindings: clock: mediatek: regroup MT8188 dt-bindings into MT8186 Louis-Alexis Eyraud
2026-07-09 14:03   ` AngeloGioacchino Del Regno
2026-07-09 18:10   ` Conor Dooley
2026-07-10 15:09   ` sashiko-bot
2026-07-09 13:42 ` [PATCH v2 06/18] dt-bindings: clock: mediatek: regroup MT8192 " Louis-Alexis Eyraud
2026-07-09 14:03   ` AngeloGioacchino Del Regno
2026-07-09 18:10   ` Conor Dooley
2026-07-10 15:09   ` sashiko-bot
2026-07-09 13:42 ` [PATCH v2 07/18] dt-bindings: clock: mediatek: regroup MT8195 " Louis-Alexis Eyraud
2026-07-09 14:03   ` AngeloGioacchino Del Regno
2026-07-09 18:10   ` Conor Dooley
2026-07-09 13:42 ` [PATCH v2 08/18] dt-bindings: clock: mediatek: Add MT8189 clocks Louis-Alexis Eyraud
2026-07-09 14:05   ` AngeloGioacchino Del Regno
2026-07-09 18:12     ` Conor Dooley
2026-07-09 13:42 ` [PATCH v2 09/18] clk: mediatek: Add MT8189 apmixedsys clock support Louis-Alexis Eyraud
2026-07-10 15:09   ` sashiko-bot
2026-07-09 13:42 ` [PATCH v2 10/18] clk: mediatek: Add MT8189 topckgen " Louis-Alexis Eyraud
2026-07-10 15:09   ` sashiko-bot
2026-07-09 13:42 ` [PATCH v2 11/18] clk: mediatek: Add MT8189 vlpckgen " Louis-Alexis Eyraud
2026-07-09 13:42 ` [PATCH v2 12/18] clk: mediatek: Add MT8189 vlpcfg " Louis-Alexis Eyraud
2026-07-09 13:42 ` [PATCH v2 13/18] clk: mediatek: Add MT8189 bus " Louis-Alexis Eyraud
2026-07-09 13:42 ` [PATCH v2 14/18] clk: mediatek: Add MT8189 dbgao " Louis-Alexis Eyraud
2026-07-09 13:42 ` [PATCH v2 15/18] clk: mediatek: Add MT8189 dvfsrc " Louis-Alexis Eyraud
2026-07-10 15:09   ` sashiko-bot [this message]
2026-07-09 13:42 ` [PATCH v2 16/18] clk: mediatek: Add MT8189 i2c " Louis-Alexis Eyraud
2026-07-09 13:42 ` [PATCH v2 17/18] clk: mediatek: Add MT8189 scp " Louis-Alexis Eyraud
2026-07-10 15:09   ` sashiko-bot
2026-07-09 13:42 ` [PATCH v2 18/18] clk: mediatek: Add MT8189 ufs " Louis-Alexis Eyraud
2026-07-10 15:09   ` 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=20260710150910.B0FAC1F0155D@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=louisalexis.eyraud@collabora.com \
    --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 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.