mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] scsi: ufs: core: Do not access null point in ufshpb_remove
@ 2023-09-20  9:12 Zhang Hui
  2023-09-20 14:38 ` Bart Van Assche
  0 siblings, 1 reply; 2+ messages in thread
From: Zhang Hui @ 2023-09-20  9:12 UTC (permalink / raw)
  To: alim.akhtar, avri.altman, bvanassche, jejb, martin.petersen
  Cc: linux-scsi, linux-kernel, stanley.chu, peng.zhou, yujiaochen,
	yudongbin, zhanghui31

From: zhanghui <zhanghui31@xiaomi.com>

If hpb is not enabled or not allowed, some points will not be allocated in
init flow, so access them will trigger KE in ufshpb remove flow.

Call trace in rmmod ko:
destroy_workqueue+0x1c/0x234
ufshpb_remove+0x40/0x50
ufshcd_remove+0x3c/0xd0
...

Signed-off-by: zhanghui <zhanghui31@xiaomi.com>
---
 drivers/ufs/core/ufshpb.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/ufs/core/ufshpb.c b/drivers/ufs/core/ufshpb.c
index 255f8b38d0c2..fa345e161cb8 100644
--- a/drivers/ufs/core/ufshpb.c
+++ b/drivers/ufs/core/ufshpb.c
@@ -2656,6 +2656,9 @@ void ufshpb_init(struct ufs_hba *hba)
 
 void ufshpb_remove(struct ufs_hba *hba)
 {
+	if (!ufshpb_is_allowed(hba) || !hba->dev_info.hpb_enabled)
+		return;
+
 	mempool_destroy(ufshpb_page_pool);
 	mempool_destroy(ufshpb_mctx_pool);
 	kmem_cache_destroy(ufshpb_mctx_cache);
-- 
2.34.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-09-20 14:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-20  9:12 [PATCH] scsi: ufs: core: Do not access null point in ufshpb_remove Zhang Hui
2023-09-20 14:38 ` Bart Van Assche

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®