From: Hongyan Xu <getshell@seu.edu.cn>
To: gregkh@linuxfoundation.org, sashal@kernel.org, arnd@arndb.de
Cc: linusw@kernel.org, brgl@kernel.org, stable@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org,
jianhao.xu@seu.edu.cn, getshell@seu.edu.cn
Subject: [RFC PATCH 6.6.y 1/4] misc: ti-st: publish the transport only after probe succeeds
Date: Fri, 24 Jul 2026 13:28:39 +0800 [thread overview]
Message-ID: <20260724052842.1052-2-getshell@seu.edu.cn> (raw)
In-Reply-To: <20260724052842.1052-1-getshell@seu.edu.cn>
kim_probe() stores the platform device in st_kim_devices[] before the
transport core and the remaining resources are initialized. If a later
probe step fails, st_kim_ref() can follow that published device to freed
driver data.
Publish the device only after probe has completed, and clear drvdata when
rolling probe back.
Fixes: 53618cc1e51e ("Staging: sources for ST core")
Cc: stable@vger.kernel.org
Signed-off-by: Hongyan Xu <getshell@seu.edu.cn>
---
drivers/misc/ti-st/st_kim.c | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/drivers/misc/ti-st/st_kim.c b/drivers/misc/ti-st/st_kim.c
index fe682e0..ec265a6 100644
--- a/drivers/misc/ti-st/st_kim.c
+++ b/drivers/misc/ti-st/st_kim.c
@@ -699,15 +699,7 @@ static int kim_probe(struct platform_device *pdev)
{
struct kim_data_s *kim_gdata;
struct ti_st_plat_data *pdata = pdev->dev.platform_data;
- int err;
-
- if ((pdev->id != -1) && (pdev->id < MAX_ST_DEVICES)) {
- /* multiple devices could exist */
- st_kim_devices[pdev->id] = pdev;
- } else {
- /* platform's sure about existence of 1 device */
- st_kim_devices[0] = pdev;
- }
+ int err, id = 0;
kim_gdata = kzalloc(sizeof(struct kim_data_s), GFP_KERNEL);
if (!kim_gdata) {
@@ -762,12 +754,16 @@ static int kim_probe(struct platform_device *pdev)
kim_gdata, &version_fops);
debugfs_create_file("protocols", S_IRUGO, kim_debugfs_dir,
kim_gdata, &list_fops);
+ if (pdev->id >= 0 && pdev->id < MAX_ST_DEVICES)
+ id = pdev->id;
+ st_kim_devices[id] = pdev;
return 0;
err_sysfs_group:
st_core_exit(kim_gdata->core_data);
err_core_init:
+ platform_set_drvdata(pdev, NULL);
kfree(kim_gdata);
return err;
--
2.50.1.windows.1
next prev parent reply other threads:[~2026-07-24 5:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-24 5:28 [RFC PATCH 6.6.y 0/4] misc: ti-st: close transport removal races Hongyan Xu
2026-07-24 5:28 ` Hongyan Xu [this message]
2026-07-24 5:28 ` [RFC PATCH 6.6.y 2/4] misc: ti-st: account published transport users Hongyan Xu
2026-07-24 5:28 ` [RFC PATCH 6.6.y 3/4] misc: ti-st: drain published users before transport removal Hongyan Xu
2026-07-24 5:28 ` [RFC PATCH 6.6.y 4/4] misc: ti-st: synchronize TTY teardown with " Hongyan Xu
2026-08-03 9:14 ` [RFC PATCH 6.6.y 0/4] misc: ti-st: close transport removal races Greg KH
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=20260724052842.1052-2-getshell@seu.edu.cn \
--to=getshell@seu.edu.cn \
--cc=arnd@arndb.de \
--cc=brgl@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=jianhao.xu@seu.edu.cn \
--cc=linusw@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sashal@kernel.org \
--cc=stable@vger.kernel.org \
/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®