Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Pengpeng Hou" <hppiscas@163.com>
Cc: imx@lists.linux.dev, Frank.Li@kernel.org
Subject: Re: [PATCH] pmdomain: imx: Propagate SCU provider registration failures
Date: Sun, 06 Sep 2026 03:50:26 +0000	[thread overview]
Message-ID: <20260906035026.C27331F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260906033806.84671-1-hppiscas@163.com>

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

Pre-existing issues:
- [High] Silent ignoring of memory allocation failures (-ENOMEM) during PM domain initialization.
- [Medium] imx_sc_get_pd_power() returns garbage union data on RPC failure.
- [Medium] Uninitialized kernel stack memory is sent to the SCU firmware via IPC messages, leaking 1-2 bytes of kernel stack memory per call.
--

commit 0f88257985e0a31b74141d36afa67a7454eaca5c
Author: Pengpeng Hou <hppiscas@163.com>

pmdomain: imx: Propagate SCU provider registration failures

imx_scu_init_pm_domains() ignores of_genpd_add_provider_onecell() and
returns success even when none of the initialized domains are published to
DT consumers.

Return the provider error and remove the initialized domains in reverse
order before devm releases their backing storage on probe failure.

> diff --git a/drivers/pmdomain/imx/scu-pd.c b/drivers/pmdomain/imx/scu-pd.c
> index e3f9e741daf76..05d4364f34be9 100644
> --- a/drivers/pmdomain/imx/scu-pd.c
> +++ b/drivers/pmdomain/imx/scu-pd.c
[ ... ]
> @@ -503,7 +503,13 @@ static int imx_scu_init_pm_domains(struct device *dev,
>  	pd_data->num_domains = count;
>  	pd_data->xlate = imx_scu_pd_xlate;
>  
> -	of_genpd_add_provider_onecell(dev->of_node, pd_data);
> +	ret = of_genpd_add_provider_onecell(dev->of_node, pd_data);
> +	if (ret) {
> +		while (count)
> +			pm_genpd_remove(domains[--count]);
> +
> +		return ret;
> +	}
>  
>  	return 0;
>  }

While reviewing this patch, I noticed a few pre-existing issues in this file.

drivers/pmdomain/imx/scu-pd.c:imx_sc_get_pd_power() {
    ...
	struct imx_sc_msg_req_get_resource_power_mode msg;
    ...
	msg.data.req.resource = rsrc;

	ret = imx_scu_call_rpc(pm_ipc_handle, &msg, true);
    ...
}

[Severity: Medium]
This is a pre-existing issue, but does this leak uninitialized kernel stack
memory to the firmware? The msg structure is allocated on the stack and only
partially initialized. Due to padding, some bytes remain uninitialized before
the full structure is transmitted via imx_scu_call_rpc(). A similar situation
occurs with struct imx_sc_msg_req_set_resource_power_mode msg in
imx_sc_pd_power().


drivers/pmdomain/imx/scu-pd.c:imx_sc_get_pd_power() {
    ...
	ret = imx_scu_call_rpc(pm_ipc_handle, &msg, true);
	if (ret)
		dev_err(dev, "failed to get power resource %d mode, ret %d\n",
			rsrc, ret);

	return msg.data.resp.mode;
}

[Severity: Medium]
This is a pre-existing issue, but when imx_scu_call_rpc() fails, does this
return uninitialized or overlapped union data instead of propagating the error
code? The returned garbage data might randomly match IMX_SC_PM_PW_MODE_ON,
leading to incorrect power state initialization.


drivers/pmdomain/imx/scu-pd.c:imx_scu_init_pm_domains() {
    ...
	for (i = 0; i < pd_soc->num_ranges; i++) {
		for (j = 0; j < pd_ranges[i].num; j++) {
			sc_pd = imx_scu_add_pm_domain(dev, j, &pd_ranges[i]);
			if (IS_ERR_OR_NULL(sc_pd))
				continue;
    ...
}

[Severity: High]
This is a pre-existing issue, but are memory allocation failures silently
ignored here? If devm_kzalloc() inside imx_scu_add_pm_domain() returns
ERR_PTR(-ENOMEM), catching this with IS_ERR_OR_NULL(sc_pd) and continuing
the loop fails to propagate the resource management error, which could leave
dependent devices broken.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260906033806.84671-1-hppiscas@163.com?part=1

      reply	other threads:[~2026-09-06  3:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-06  3:38 [PATCH] pmdomain: imx: Propagate SCU provider registration failures Pengpeng Hou
2026-09-06  3:50 ` sashiko-bot [this message]

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=20260906035026.C27331F00A3D@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=hppiscas@163.com \
    --cc=imx@lists.linux.dev \
    --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