From: Conor Dooley <conor@kernel.org>
To: Guangshuo Li <lgs201920130244@gmail.com>
Cc: Conor Dooley <conor.dooley@microchip.com>,
Daire McNamara <daire.mcnamara@microchip.com>,
Felix Gu <ustc.gu@gmail.com>,
linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] soc: mpfs: use kref cleanup on probe failure
Date: Thu, 8 Oct 2026 14:14:42 +0100 [thread overview]
Message-ID: <20261008-590aec0ad34ba6c65b269ed3@squawk> (raw)
In-Reply-To: <20261007121743.192486-1-lgs201920130244@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1972 bytes --]
On Wed, Oct 07, 2026 at 08:17:43PM +0800, Guangshuo Li wrote:
> After kref_init(), the device_get_match_data() failure path frees the
> mailbox channel and sys_controller directly, bypassing the matching
> kref_put() for the initial reference.
>
> Use mpfs_sys_controller_put() on this path so that the initial
> reference established by kref_init() is released through the existing
> kref release callback.
>
> Rename the error label to reflect that cleanup is now performed
> through the kref helper.
>
> This issue was found by manual code inspection.
>
> Fixes: 75ef23397558 ("soc: microchip: mpfs-sys-controller: fix resource leak on probe error")
> Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
> ---
> v2:
> - Add the missing Signed-off-by tag.
> - Rename out_free_channel to out_put as suggested by Felix.
Applied, thanks.
Cheers,
Conor.
>
> drivers/soc/microchip/mpfs-sys-controller.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/soc/microchip/mpfs-sys-controller.c b/drivers/soc/microchip/mpfs-sys-controller.c
> index 0400a01b2338..ef27e1083f0f 100644
> --- a/drivers/soc/microchip/mpfs-sys-controller.c
> +++ b/drivers/soc/microchip/mpfs-sys-controller.c
> @@ -159,7 +159,7 @@ static int mpfs_sys_controller_probe(struct platform_device *pdev)
> of_data = (struct mpfs_syscon_config *) device_get_match_data(dev);
> if (!of_data) {
> ret = dev_err_probe(dev, -EINVAL, "Error getting match data\n");
> - goto out_free_channel;
> + goto out_put;
> }
>
> for (i = 0; i < of_data->nb_subdevs; i++) {
> @@ -173,8 +173,9 @@ static int mpfs_sys_controller_probe(struct platform_device *pdev)
>
> return 0;
>
> -out_free_channel:
> - mbox_free_channel(sys_controller->chan);
> +out_put:
> + mpfs_sys_controller_put(sys_controller);
> + return ret;
> out_free:
> kfree(sys_controller);
> return ret;
> --
> 2.43.0
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
prev parent reply other threads:[~2026-10-08 13:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-07 12:17 Guangshuo Li
2026-10-08 13:14 ` Conor Dooley [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=20261008-590aec0ad34ba6c65b269ed3@squawk \
--to=conor@kernel.org \
--cc=conor.dooley@microchip.com \
--cc=daire.mcnamara@microchip.com \
--cc=lgs201920130244@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=ustc.gu@gmail.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
all inboxes | Powered by JetHome®