Linux clock framework development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Brian Masney" <bmasney@redhat.com>
Cc: wsa+renesas@sang-engineering.com, linux-clk@vger.kernel.org
Subject: Re: [PATCH 4/4] clk: renesas: convert drivers over to use subsys_platform_driver()
Date: Tue, 08 Sep 2026 18:09:52 +0000	[thread overview]
Message-ID: <20260908180952.793A41F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260908-subsys_initcall-v1-4-cbccf4cd4288@redhat.com>

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

Pre-existing issues:
- [High] Missing of_genpd_del_provider() on error paths leads to stale OF PM domain provider registrations and Critical Use-After-Free.
--

commit 26447fc60447ea2456fb17817135325feb86bdfb
Author: Brian Masney <bmasney@redhat.com>
Subject: clk: renesas: convert drivers over to use subsys_platform_driver()

Reduce boilerplate code in the drivers and convert them over to use
subsys_platform_driver().

> diff --git a/drivers/clk/renesas/renesas-cpg-mssr.c b/drivers/clk/renesas/renesas-cpg-mssr.c
> index 80f4403ea2baf..87b555e38980a 100644
> --- a/drivers/clk/renesas/renesas-cpg-mssr.c
> +++ b/drivers/clk/renesas/renesas-cpg-mssr.c
[ ... ]
> -static int __init cpg_mssr_init(void)
> -{
> -	return platform_driver_probe(&cpg_mssr_driver, cpg_mssr_probe);
> -}
> -
> -subsys_initcall(cpg_mssr_init);
> +subsys_platform_driver_probe(cpg_mssr_driver, cpg_mssr_probe);

[Severity: High]
This is a pre-existing issue, but I noticed a potential use-after-free
on the error path for cpg_mssr_probe().

In cpg_mssr_add_clk_domain(), the OF provider is successfully registered:

    return of_genpd_add_provider_simple(np, genpd);

However, there doesn't seem to be a corresponding devres cleanup registered
for this. If cpg_mssr_probe() fails later on, the devres cleanup routine
will call pm_genpd_remove() to unregister the PM domain.

Because of_genpd_add_provider_simple() sets genpd->has_provider = true,
pm_genpd_remove() will abort with -EBUSY and fail to remove the domain
from the global gpd_list.

Devres will then free the devm-allocated driver structure, which contains
the genpd struct.

Does this leave the global gpd_list and of_genpd_providers lists with
dangling pointers to the freed genpd struct, leading to memory corruption
when those lists are accessed later?

> diff --git a/drivers/clk/renesas/rzg2l-cpg.c b/drivers/clk/renesas/rzg2l-cpg.c
> index 7f8decef92fd9..f6293c968bcf9 100644
> --- a/drivers/clk/renesas/rzg2l-cpg.c
> +++ b/drivers/clk/renesas/rzg2l-cpg.c
[ ... ]
> -static int __init rzg2l_cpg_init(void)
> -{
> -	return platform_driver_probe(&rzg2l_cpg_driver, rzg2l_cpg_probe);
> -}
> -
> -subsys_initcall(rzg2l_cpg_init);
> +subsys_platform_driver_probe(rzg2l_cpg_driver, rzg2l_cpg_probe);

[Severity: High]
This is the same pre-existing issue as above, but affecting the error path 
in rzg2l_cpg_probe().

In rzg2l_cpg_add_clk_domain(), the OF provider is registered with
of_genpd_add_provider_simple(np, genpd) but lacks a devres cleanup action.

If the probe fails after this point, could this lead to the same resource
leak and use-after-free scenario when the PM domain lists are subsequently
accessed?

> diff --git a/drivers/clk/renesas/rzv2h-cpg.c b/drivers/clk/renesas/rzv2h-cpg.c
> index 63f13fe4e4b0e..7ce94680c79a2 100644
> --- a/drivers/clk/renesas/rzv2h-cpg.c
> +++ b/drivers/clk/renesas/rzv2h-cpg.c
[ ... ]
> -static int __init rzv2h_cpg_init(void)
> -{
> -	return platform_driver_probe(&rzv2h_cpg_driver, rzv2h_cpg_probe);
> -}
> -
> -subsys_initcall(rzv2h_cpg_init);
> +subsys_platform_driver_probe(rzv2h_cpg_driver, rzv2h_cpg_probe);

[Severity: High]
Similarly, this pre-existing issue appears to affect rzv2h_cpg_probe().

In rzv2h_cpg_add_pm_domains(), the provider is registered via
of_genpd_add_provider_simple(np, &pd->genpd) without a cleanup handler.

Would a probe failure in this driver also result in dangling pointers in
the global PM domain lists?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260908-subsys_initcall-v1-0-cbccf4cd4288@redhat.com?part=4

  reply	other threads:[~2026-09-08 18:09 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-08 17:47 [PATCH 0/4] driver: core: add subsys_platform_driver() to reduce boilerplate code in drivers Brian Masney
2026-09-08 17:47 ` [PATCH 1/4] driver: core: add subsys_driver() macro Brian Masney
2026-09-08 17:58   ` sashiko-bot
2026-09-08 18:19     ` Brian Masney
2026-09-09  7:49       ` Geert Uytterhoeven
2026-09-09 11:44   ` Abel Vesa
2026-09-09 15:14   ` Geert Uytterhoeven
2026-09-08 17:47 ` [PATCH 2/4] driver: core: platform: add subsys_platform_driver() macro Brian Masney
2026-09-09 11:44   ` Abel Vesa
2026-09-09 15:16   ` Geert Uytterhoeven
2026-09-08 17:47 ` [PATCH 3/4] clk: qcom: convert drivers over to use subsys_platform_driver() Brian Masney
2026-09-09 11:25   ` Konrad Dybcio
2026-09-09 11:45   ` Abel Vesa
2026-09-09 12:10     ` Brian Masney
2026-09-08 17:47 ` [PATCH 4/4] clk: renesas: " Brian Masney
2026-09-08 18:09   ` sashiko-bot [this message]
2026-09-09 15:19   ` Geert Uytterhoeven
2026-09-09 14:40 ` [PATCH 0/4] driver: core: add subsys_platform_driver() to reduce boilerplate code in drivers Pankaj Patil

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=20260908180952.793A41F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bmasney@redhat.com \
    --cc=linux-clk@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=wsa+renesas@sang-engineering.com \
    /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