From: Guangshuo Li <lgs201920130244@gmail.com>
To: conor.dooley@microchip.com, daire.mcnamara@microchip.com
Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
ustc.gu@gmail.com, lgs201920130244@gmail.com
Subject: [PATCH] soc: mpfs: use kref cleanup on probe failure
Date: Thu, 24 Sep 2026 19:00:54 +0800 [thread overview]
Message-ID: <20260924110054.1553880-1-lgs201920130244@gmail.com> (raw)
After kref_init(), the device_get_match_data() failure path jumps to
out_free_channel. That path frees the mailbox channel and then falls
through to kfree(), bypassing mpfs_sys_controller_put() for the initial
reference.
Call mpfs_sys_controller_put() on that path and return immediately. The
existing kref release callback then performs the matching cleanup, and
the return prevents a second free through out_free. This is the minimal
change needed to keep the initialized lifetime balanced.
Fixes: 75ef23397558 ("soc: microchip: mpfs-sys-controller: fix resource leak on probe error")
---
drivers/soc/microchip/mpfs-sys-controller.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/soc/microchip/mpfs-sys-controller.c b/drivers/soc/microchip/mpfs-sys-controller.c
index 0400a01b2338..379e4f649faa 100644
--- a/drivers/soc/microchip/mpfs-sys-controller.c
+++ b/drivers/soc/microchip/mpfs-sys-controller.c
@@ -174,7 +174,8 @@ static int mpfs_sys_controller_probe(struct platform_device *pdev)
return 0;
out_free_channel:
- mbox_free_channel(sys_controller->chan);
+ mpfs_sys_controller_put(sys_controller);
+ return ret;
out_free:
kfree(sys_controller);
return ret;
base-commit: f03c39de3a1307371a4032757cd1732e91087c7d
--
2.43.0
next reply other threads:[~2026-09-24 11:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-24 11:00 Guangshuo Li [this message]
2026-09-24 16:04 ` Felix Gu
2026-10-02 17:22 ` Conor Dooley
2026-10-07 11:38 ` Guangshuo 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=20260924110054.1553880-1-lgs201920130244@gmail.com \
--to=lgs201920130244@gmail.com \
--cc=conor.dooley@microchip.com \
--cc=daire.mcnamara@microchip.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®