Linux clock framework development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Yu-Chun Lin" <eleanor.lin@realtek.com>
Cc: devicetree@vger.kernel.org, conor+dt@kernel.org,
	linux-clk@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH v13 04/11] clk: realtek: Introduce common probe() and remove()
Date: Wed, 12 Aug 2026 02:08:27 +0000	[thread overview]
Message-ID: <20260812020827.D656B1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260812020009.3480538-5-eleanor.lin@realtek.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] rtk_clk_remove() manually clears regmap pointers before devres unregisters the clocks, creating a fatal window for NULL pointer dereferences.
--

--- Patch [4]: [PATCH v13 04/11] clk: realtek: Introduce common probe() and remove() ---
commit 85dc7ea7ea58332e5239ff20ff6e6669d56fbb6a
Author: Cheng-Yu Lee <cylee12@realtek.com>

clk: realtek: Introduce common probe() and remove()

This commit introduces common probe and remove functions for Realtek clock
drivers. It handles setting up a shared regmap, registering clock hardware,
and optionally creating an auxiliary device for the reset controller.

> diff --git a/drivers/clk/realtek/clk-rtk-common.c b/drivers/clk/realtek/clk-rtk-common.c
> new file mode 100644
> --- /dev/null
> +++ b/drivers/clk/realtek/clk-rtk-common.c
[ ... ]
> +void rtk_clk_remove(struct platform_device *pdev)
> +{
> +	const struct rtk_clk_desc *desc = platform_get_drvdata(pdev);
> +
> +	if (!desc)
> +		return;
> +
> +	for (int i = 0; i < desc->num_clks; i++)
> +		desc->clks[i]->regmap = NULL;

[Severity: High]
Could this clear operation introduce a NULL pointer dereference window?

Since the clocks are registered using devm_clk_hw_register() in
rtk_clk_probe(), they remain active and visible to the Common Clock Framework
until the devres release callbacks execute. This devres cleanup happens
after rtk_clk_remove() returns.

If a consumer or an interrupt invokes a clock operation while the device is
being unbound, the callback might attempt to access the hardware using this
newly cleared NULL regmap pointer.

Because the regmap is obtained via device_node_to_regmap(), which returns a
syscon regmap that is never freed, is it necessary to clear these pointers
during driver unbind?

> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260812020009.3480538-1-eleanor.lin@realtek.com?part=4

  reply	other threads:[~2026-08-12  2:08 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-12  1:59 [PATCH v13 00/11] clk / reset: realtek: Add RTD1625 clock and reset support Yu-Chun Lin
2026-08-12  1:59 ` [PATCH v13 01/11] dt-bindings: clock: Add Realtek RTD1625 Clock & Reset Controller Yu-Chun Lin
2026-08-12  8:48   ` Krzysztof Kozlowski
2026-08-12  9:41     ` Yu-Chun Lin [林祐君]
2026-08-12  9:49       ` Krzysztof Kozlowski
2026-08-12 10:22         ` Yu-Chun Lin [林祐君]
2026-08-12  2:00 ` [PATCH v13 02/11] reset: Add Realtek basic reset support Yu-Chun Lin
2026-08-12  2:00 ` [PATCH v13 03/11] reset: realtek: Add RTD1625 reset controller driver Yu-Chun Lin
2026-08-12  2:10   ` sashiko-bot
2026-08-12  2:00 ` [PATCH v13 04/11] clk: realtek: Introduce common probe() and remove() Yu-Chun Lin
2026-08-12  2:08   ` sashiko-bot [this message]
2026-08-12  2:00 ` [PATCH v13 05/11] clk: realtek: Add support for phase locked loops (PLLs) Yu-Chun Lin
2026-08-12  2:11   ` sashiko-bot
2026-08-12  2:00 ` [PATCH v13 06/11] clk: realtek: Add support for gate clock Yu-Chun Lin
2026-08-12  2:00 ` [PATCH v13 07/11] clk: realtek: Add support for mux clock Yu-Chun Lin
2026-08-12  2:00 ` [PATCH v13 08/11] clk: realtek: Add support for MMC-tuned PLL clocks Yu-Chun Lin
2026-08-12  2:00 ` [PATCH v13 09/11] clk: realtek: Add RTD1625-CRT clock controller driver Yu-Chun Lin
2026-08-12  2:16   ` sashiko-bot
2026-08-12  2:00 ` [PATCH v13 10/11] clk: realtek: Add RTD1625-ISO " Yu-Chun Lin
2026-08-12  2:18   ` sashiko-bot
2026-08-12  2:00 ` [PATCH v13 11/11] arm64: dts: realtek: Add clock support for RTD1625 Yu-Chun Lin

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=20260812020827.D656B1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=eleanor.lin@realtek.com \
    --cc=linux-clk@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