Skip to contentSkip to conversation

scsi: ufs: core: Add NULL check in ufshcd_mcq_compl_pending_transfer()

PATCH In review Chenyuan Yang 3 participants 3 messages Apr 12, 2025 – Apr 14, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: ufs: core: Add NULL check in ufshcd_mcq_compl_pending_transfer()

Add a NULL check for the returned hwq pointer by ufshcd_mcq_req_to_hwq().

This is similar to the fix in commit 74736103fb41 ("scsi: ufs: core: Fix ufshcd_abort_one racing issue").

Fixes ab248643d3d6 ("scsi: ufs: core: Add error handling for MCQ mode")
---
 drivers/ufs/core/ufshcd.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/ufs/core/ufshcd.c +2 -0
index 0534390c2a35..fd39e10c2043 100644
@@ -5692,6 +5692,8 @@ static void ufshcd_mcq_compl_pending_transfer(struct ufs_hba *hba,
 			continue;
 
 		hwq = ufshcd_mcq_req_to_hwq(hba, scsi_cmd_to_rq(cmd));
+		if (!hwq)
+			continue;
 
 		if (force_compl) {
 			ufshcd_mcq_compl_all_cqes_lock(hba, hwq);
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 31 lines · Chenyuan Yang

External email : Please do not click links or open attachments until you have verified the sender or the content.

Add a NULL check for the returned hwq pointer by
ufshcd_mcq_req_to_hwq().

This is similar to the fix in commit 74736103fb41 ("scsi: ufs: core: Fix ufshcd_abort_one racing issue").

Fixes ab248643d3d6 ("scsi: ufs: core: Add error handling for MCQ

mode")
---
 drivers/ufs/core/ufshcd.c | 2 ++

 1 file changed, 2 insertions(+)
drivers/ufs/core/ufshcd.c +2 -0
index 0534390c2a35..fd39e10c2043 100644
@@ -5692,6 +5692,8 @@ static void
 ufshcd_mcq_compl_pending_transfer(struct ufs_hba *hba,
                         continue;
 
                 hwq = ufshcd_mcq_req_to_hwq(hba,
 scsi_cmd_to_rq(cmd));
+               if (!hwq)
+                       continue;
 
Quoted 5 lines

                if (force_compl) { ufshcd_mcq_compl_all_cqes_lock(hba, hwq); --
2.34.1

reviewer Reviewed-by on v1 1/1
#2 lore raw
In reply to Chenyuan Yang
Quoted 16 lines · Chenyuan Yang

Add a NULL check for the returned hwq pointer by ufshcd_mcq_req_to_hwq().

This is similar to the fix in commit 74736103fb41 ("scsi: ufs: core: Fix ufshcd_abort_one racing issue").

Fixes ab248643d3d6 ("scsi: ufs: core: Add error handling for MCQ mode")
---
  drivers/ufs/core/ufshcd.c | 2 ++
  1 file changed, 2 insertions(+)
drivers/ufs/core/ufshcd.c +0 -0
index 0534390c2a35..fd39e10c2043 100644

drivers/ufs/core/ufshcd.c static void ufshcd_mcq_compl_pending_transfer(struct ufs_hba *hba, · line 5699

Quoted 8 lines
drivers/ufs/core/ufshcd.c +2 -0
@@ -5692,6 +5692,8 @@ static void ufshcd_mcq_compl_pending_transfer(struct ufs_hba *hba,
  			continue;
 
  		hwq = ufshcd_mcq_req_to_hwq(hba, scsi_cmd_to_rq(cmd));
+		if (!hwq)
+			continue;
 
  		if (force_compl) {
  			ufshcd_mcq_compl_all_cqes_lock(hba, hwq);