From: Johan Hovold <johan@kernel.org>
To: Haotian Zhang <vulab@iscas.ac.cn>
Cc: Vaibhav Hiremath <hvaibhav.linux@gmail.com>,
Alex Elder <elder@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
greybus-dev@lists.linaro.org, linux-staging@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: greybus: arche-platform: fix pm_notifier leak in probe error path
Date: Tue, 4 Nov 2025 11:29:17 +0100 [thread overview]
Message-ID: <aQnVfdHKk7TD0JwM@hovoldconsulting.com> (raw)
In-Reply-To: <20251104090825.224-1-vulab@iscas.ac.cn>
On Tue, Nov 04, 2025 at 05:08:25PM +0800, Haotian Zhang wrote:
> In arche_platform_probe(), if arche_platform_coldboot_seq() fails after
> register_pm_notifier() succeeds, the function returns without unregistering
> the pm_notifier, leading to a resource leak.
>
> Add unregister_pm_notifier() call in the err_coldboot error path to
> properly clean up the registered notifier on failure.
>
> Fixes: d29b67d44a7c ("greybus: arche-platform: Add support for init-off feature")
> Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
> ---
> drivers/staging/greybus/arche-platform.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/staging/greybus/arche-platform.c b/drivers/staging/greybus/arche-platform.c
> index d48464390f58..9c5bb5dae187 100644
> --- a/drivers/staging/greybus/arche-platform.c
> +++ b/drivers/staging/greybus/arche-platform.c
> @@ -545,6 +545,7 @@ static int arche_platform_probe(struct platform_device *pdev)
> return 0;
>
> err_coldboot:
> + unregister_pm_notifier(&arche_pdata->pm_notifier);
> mutex_unlock(&arche_pdata->platform_state_mutex);
This looks mostly correct, but please make sure to release the lock
before deregistering the notifier so that things are unwound in reverse
order.
It would be even better to move the mutex unlock to where the driver
jumps to err_coldboot since it is only held in that conditional since
the offending commit.
> err_device_remove:
> device_remove_file(&pdev->dev, &dev_attr_state);
Johan
prev parent reply other threads:[~2025-11-04 10:29 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-04 9:08 Haotian Zhang
2025-11-04 10:29 ` Johan Hovold [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=aQnVfdHKk7TD0JwM@hovoldconsulting.com \
--to=johan@kernel.org \
--cc=elder@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=greybus-dev@lists.linaro.org \
--cc=hvaibhav.linux@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=vulab@iscas.ac.cn \
/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
all inboxes | Powered by JetHome®