Skip to contentSkip to conversation

scsi: ufs: core: Do not access null point in ufshpb_remove

PATCH In review Zhang Hui 2 participants 2 messages Sep 20, 2023

Subsystems (2)
lore
Share & tools
lore

Zhang Hui

author
#0 lore raw

PATCH 1/1 scsi: ufs: core: Do not access null point in ufshpb_remove

From: zhanghui <[email protected]>

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

...

---
 drivers/ufs/core/ufshpb.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/ufs/core/ufshpb.c +3 -0
index 255f8b38d0c2..fa345e161cb8 100644
@@ -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);
Signature · 1 line
2.34.1
#1 lore raw
Quoted 3 lines · Zhang Hui

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.

Since the HPB code has been removed from the kernel, I don't think that this patch applies. Please always start from the latest kernel version when preparing patches.

Thanks,

Bart.