From: Po-Wen Kao <powenkao@google.com>
To: linux-scsi@vger.kernel.org
Cc: Konstantin Vyshetsky <vkon@google.com>,
Randall Huang <huangrandall@google.com>,
Alim Akhtar <alim.akhtar@samsung.com>,
Bart Van Assche <bvanassche@acm.org>,
Bean Huo <beanhuo@micron.com>,
Stanley Jhu <stanleyjhu@google.com>,
"James E . J . Bottomley"
<James.Bottomley@HansenPartnership.com>,
"Martin K . Petersen" <mkp@kernel.org>,
Peter Wang <peter.wang@mediatek.com>,
Can Guo <can.guo@oss.qualcomm.com>,
linux-kernel@vger.kernel.org, Brian Kao <powenkao@google.com>,
stable@vger.kernel.org, John Garry <john.garry@linux.dev>,
Li Qiang <liqiang01@kylinos.cn>,
HOYOUNG SEO <hy50.seo@samsung.com>,
Hyeoncheol Jeong <hyenc.jeong@samsung.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Asutosh Das <quic_asutoshd@quicinc.com>
Subject: [PATCH v3 1/3] scsi: ufs: core: Remove debugfs before removing SCSI host
Date: Wed, 25 Nov 2026 19:33:59 +0800 [thread overview]
Message-ID: <20261125113435.1426680-2-powenkao@google.com> (raw)
In-Reply-To: <20261125113435.1426680-1-powenkao@google.com>
From: Brian Kao <powenkao@google.com>
ufs_debugfs_hba_exit() is currently called only from ufshcd_hba_exit(),
after scsi_remove_host() has removed hba->ufs_device_wlun. Active
debugfs write handlers (e.g. exception_event_mask) and
hba->debugfs_ee_work call ufs_debugfs_get_user_access() ->
ufshcd_rpm_get_sync(), which can dereference a NULL or freed
hba->ufs_device_wlun during unbind.
Call ufs_debugfs_hba_exit() from ufshcd_remove() alongside
ufs_sysfs_remove_nodes(), before scsi_remove_host(), so in-flight
debugfs file operations are drained while the WLUN is still present.
Switch cancel_delayed_work_sync() to disable_delayed_work_sync()
(introduced in v6.10) so an in-flight exception event cannot re-queue
debugfs_ee_work during teardown, and clear hba->debugfs_root so the
existing ufs_debugfs_hba_exit() call in ufshcd_hba_exit() remains safe
on both normal remove and probe failure paths.
Fixes: b294ff3e3449 ("scsi: ufs: core: Enable power management for wlun")
Cc: stable@vger.kernel.org # v6.10+
Signed-off-by: Brian Kao <powenkao@google.com>
---
drivers/ufs/core/ufs-debugfs.c | 3 ++-
drivers/ufs/core/ufshcd.c | 1 +
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/ufs/core/ufs-debugfs.c b/drivers/ufs/core/ufs-debugfs.c
index 9f83628f3e2c..89753c40b27b 100644
--- a/drivers/ufs/core/ufs-debugfs.c
+++ b/drivers/ufs/core/ufs-debugfs.c
@@ -529,5 +529,6 @@ void ufs_debugfs_hba_init(struct ufs_hba *hba)
void ufs_debugfs_hba_exit(struct ufs_hba *hba)
{
debugfs_remove_recursive(hba->debugfs_root);
- cancel_delayed_work_sync(&hba->debugfs_ee_work);
+ hba->debugfs_root = NULL;
+ disable_delayed_work_sync(&hba->debugfs_ee_work);
}
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 56a77f4a2a6e..646359d446c3 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -11027,6 +11027,7 @@ void ufshcd_remove(struct ufs_hba *hba)
ufs_bsg_remove(hba);
ufs_rpmb_remove(hba);
ufs_sysfs_remove_nodes(hba->dev);
+ ufs_debugfs_hba_exit(hba);
cancel_delayed_work_sync(&hba->ufs_rtc_update_work);
blk_mq_destroy_queue(hba->tmf_queue);
blk_put_queue(hba->tmf_queue);
--
2.56.1.839.g22a8290db9-goog
next prev parent reply other threads:[~2026-11-25 11:34 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 11:33 [PATCH v3 0/3] scsi: ufs: core: Add debugfs for PA TFS/FEC error counters Po-Wen Kao
2026-11-25 11:33 ` Po-Wen Kao [this message]
2026-11-25 11:34 ` [PATCH v3 2/3] scsi: ufs: core: Defer debugfs init until after device init Po-Wen Kao
2026-11-25 11:34 ` [PATCH v3 3/3] scsi: ufs: core: Add debugfs for PA TFS/FEC error counters Po-Wen Kao
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=20261125113435.1426680-2-powenkao@google.com \
--to=powenkao@google.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=adrian.hunter@intel.com \
--cc=alim.akhtar@samsung.com \
--cc=beanhuo@micron.com \
--cc=bvanassche@acm.org \
--cc=can.guo@oss.qualcomm.com \
--cc=huangrandall@google.com \
--cc=hy50.seo@samsung.com \
--cc=hyenc.jeong@samsung.com \
--cc=john.garry@linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=liqiang01@kylinos.cn \
--cc=mkp@kernel.org \
--cc=peter.wang@mediatek.com \
--cc=quic_asutoshd@quicinc.com \
--cc=stable@vger.kernel.org \
--cc=stanleyjhu@google.com \
--cc=vkon@google.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®