Devicetree
 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 10/18] clk: mediatek: Add MT8189 topckgen clock support
Date: Fri, 10 Jul 2026 15:09:09 +0000	[thread overview]
Message-ID: <20260710150909.C3FA51F01559@smtp.kernel.org> (raw)
In-Reply-To: <20260709-mt8189-clocks-system-base-v2-10-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 the clock notifier unregistration path on driver removal.
--

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

clk: mediatek: Add MT8189 topckgen clock support

Add support for the MT8189 topckgen clock controller, which provides
muxes and dividers for clock selection in other IP blocks.

> diff --git a/drivers/clk/mediatek/clk-mt8189-topckgen.c b/drivers/clk/mediatek/clk-mt8189-topckgen.c
> new file mode 100644
> index 0000000000000..2473b617e9d62
> --- /dev/null
> +++ b/drivers/clk/mediatek/clk-mt8189-topckgen.c

[ ... ]

> +static int clk_mt8189_reg_mfg_mux_notifier(struct device *dev,
> +					   struct clk *clk)
> +{
> +	struct mtk_mux_nb *mfg_mux_nb;
> +
> +	mfg_mux_nb = devm_kzalloc(dev, sizeof(*mfg_mux_nb), GFP_KERNEL);
> +	if (!mfg_mux_nb)
> +		return -ENOMEM;
> +
> +	mfg_mux_nb->ops = &mtk_mux_clr_set_upd_ops;
> +	mfg_mux_nb->bypass_index = 0; /* Bypass to CLK_TOP_MFG_REF_SEL */
> +
> +	return devm_mtk_clk_mux_notifier_register(dev, clk, mfg_mux_nb);
> +}

[ ... ]

> +static struct platform_driver clk_mt8189_topck_drv = {
> +	.probe = mtk_clk_simple_probe,
> +	.remove = mtk_clk_simple_remove,

[Severity: High]
This is a pre-existing issue, but does combining
devm_mtk_clk_mux_notifier_register() with mtk_clk_simple_remove() lead to a
use-after-free on driver unbind?

When the driver is unbound, the .remove callback (mtk_clk_simple_remove) is
executed first, which manually unregisters and frees the clocks.

After .remove completes, the devres framework executes its teardown routines.
This triggers the release of the notifier registered via
devm_mtk_clk_mux_notifier_register(), causing clk_notifier_unregister() to be
called with the already-freed clk pointer.

Can this sequence cause memory corruption when the freed clock pointer is
dereferenced?

> +	.driver = {
> +		.name = "clk-mt8189-topck",
> +		.of_match_table = of_match_clk_mt8189_topck,
> +	},
> +};
> +module_platform_driver(clk_mt8189_topck_drv);

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

  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 [this message]
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
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=20260710150909.C3FA51F01559@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox