From: sashiko-bot@kernel.org
To: "Slavin Liu" <bolin.liu@seu.edu.cn>
Cc: Frank.Li@kernel.org, imx@lists.linux.dev
Subject: Re: [PATCH RFC] pmdomain: imx: reject a missing bus power domain
Date: Fri, 11 Sep 2026 06:20:24 +0000 [thread overview]
Message-ID: <20260911062024.E91AB1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260911060929.94481-1-bolin.liu@seu.edu.cn>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] The error handling path in the probe function fails to remove the power domain notifier registered on `bc->bus_power_dev`, leading to a use-after-free in the genpd notifier chain.
--
commit 1bf3e63904f509711299c259aa62b9016d200e03
Author: Slavin Liu <bolin.liu@seu.edu.cn>
pmdomain: imx: reject a missing bus power domain
The named-domain attach API may return NULL for an absent name.
Treat that as -ENODEV before publishing bus_power_dev to later unwind
paths, without changing the handling of existing error pointers.
> diff --git a/drivers/pmdomain/imx/imx8m-blk-ctrl.c b/drivers/pmdomain/imx/imx8m-blk-ctrl.c
> index 479789009c7f4..9653a8ac9a6e9 100644
> --- a/drivers/pmdomain/imx/imx8m-blk-ctrl.c
> +++ b/drivers/pmdomain/imx/imx8m-blk-ctrl.c
> @@ -228,6 +228,8 @@ static int imx8m_blk_ctrl_probe(struct platform_device *pdev)
> return -ENOMEM;
>
> bc->bus_power_dev = dev_pm_domain_attach_by_name(dev, "bus");
> + if (!bc->bus_power_dev)
> + return dev_err_probe(dev, -ENODEV, "missing bus power domain\n");
[Severity: High]
This is a pre-existing issue, but I noticed a potential problem in the error
handling path of imx8m_blk_ctrl_probe(). If a failure occurs after the power
notifier is added, for example during devm_of_platform_populate():
imx8m_blk_ctrl_probe()
...
ret = dev_pm_genpd_add_notifier(bc->bus_power_dev, &bc->power_nb);
if (ret) {
...
goto cleanup_provider;
}
dev_set_drvdata(dev, bc);
ret = devm_of_platform_populate(dev);
if (ret)
goto cleanup_provider;
...
cleanup_provider:
of_genpd_del_provider(dev->of_node);
cleanup_pds:
...
dev_pm_domain_detach(bc->bus_power_dev, true);
return ret;
The error path detaches the bus power domain but fails to unregister the
notifier. Is it possible this leaves a dangling pointer to bc->power_nb when
the device memory is freed, causing a use-after-free when the bus power
domain transitions power states? Should dev_pm_genpd_remove_notifier() be
called during cleanup?
> if (IS_ERR(bc->bus_power_dev)) {
> if (PTR_ERR(bc->bus_power_dev) == -ENODEV)
> return dev_err_probe(dev, -EPROBE_DEFER,
[ ... ]
> diff --git a/drivers/pmdomain/imx/imx8mp-blk-ctrl.c b/drivers/pmdomain/imx/imx8mp-blk-ctrl.c
> index d255c20f58e21..e952b4ee75c00 100644
> --- a/drivers/pmdomain/imx/imx8mp-blk-ctrl.c
> +++ b/drivers/pmdomain/imx/imx8mp-blk-ctrl.c
> @@ -655,6 +655,8 @@ static int imx8mp_blk_ctrl_probe(struct platform_device *pdev)
> return -ENOMEM;
>
> bc->bus_power_dev = dev_pm_domain_attach_by_name(dev, "bus");
> + if (!bc->bus_power_dev)
> + return dev_err_probe(dev, -ENODEV, "missing bus power domain\n");
[Severity: High]
This isn't a bug introduced by this patch, but a similar issue appears in the
error handling path of imx8mp_blk_ctrl_probe(). If bc_data->probe(bc) fails:
imx8mp_blk_ctrl_probe()
...
ret = dev_pm_genpd_add_notifier(bc->bus_power_dev, &bc->power_nb);
if (ret) {
...
goto cleanup_provider;
}
if (bc_data->probe) {
ret = bc_data->probe(bc);
if (ret)
goto cleanup_provider;
}
...
cleanup_provider:
of_genpd_del_provider(dev->of_node);
cleanup_pds:
...
dev_pm_domain_detach(bc->bus_power_dev, true);
return ret;
Like in the i.MX8M driver, the error path detaches the bus power domain but
doesn't call dev_pm_genpd_remove_notifier() to unregister bc->power_nb. Could
this also lead to a use-after-free when 'bc' is freed?
> if (IS_ERR(bc->bus_power_dev))
> return dev_err_probe(dev, PTR_ERR(bc->bus_power_dev),
> "failed to attach bus power domain\n");
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260911060929.94481-1-bolin.liu@seu.edu.cn?part=1
next prev parent reply other threads:[~2026-09-11 6:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-11 6:09 [PATCH RFC] pmdomain: imx: reject a missing bus power domain Slavin Liu
2026-09-11 6:20 ` sashiko-bot [this message]
2026-09-11 15:01 ` Frank Li
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=20260911062024.E91AB1F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=bolin.liu@seu.edu.cn \
--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;
as well as URLs for NNTP newsgroup(s).