Skip to contentSkip to conversation

scsi: lpfc: Avoid another null dereference in lpfc_sli4_hba_unset()

PATCH Applied SeongJae Park 3 participants 3 messages Jun 23, 2020 – Jun 24, 2020

Subsystems (2)

v1 of 2 Applied Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: lpfc: Avoid another null dereference in lpfc_sli4_hba_unset()

From: SeongJae Park <[email protected]>

Commit cdb42becdd40 ("scsi: lpfc: Replace io_channels for nvme and fcp with general hdw_queues per cpu") has introduced static checker warnings for potential null dereferences in 'lpfc_sli4_hba_unset()' and commit 1ffdd2c0440d ("scsi: lpfc: resolve static checker warning in lpfc_sli4_hba_unset") has tried to fix it. However, yet another potential null dereference is remaining. This commit fixes it.

This bug was discovered and resolved using Coverity Static Analysis Security Testing (SAST) by Synopsys, Inc.

Fixes 1ffdd2c0440d ("scsi: lpfc: resolve static checker warning inlpfc_sli4_hba_unset")
Fixes cdb42becdd40 ("scsi: lpfc: Replace io_channels for nvme and fcp with general hdw_queues per cpu")
---
 drivers/scsi/lpfc/lpfc_init.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/scsi/lpfc/lpfc_init.c +2 -1
index 69a5249e007a..6637f84a3d1b 100644
@@ -11878,7 +11878,8 @@ lpfc_sli4_hba_unset(struct lpfc_hba *phba)
 	lpfc_sli4_xri_exchange_busy_wait(phba);
 
 	/* per-phba callback de-registration for hotplug event */
-	lpfc_cpuhp_remove(phba);
+	if (phba->pport)
+		lpfc_cpuhp_remove(phba);
 
 	/* Disable PCI subsystem interrupt */
 	lpfc_sli4_disable_intr(phba);
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 24 lines · SeongJae Park

From: SeongJae Park <[email protected]>

Commit cdb42becdd40 ("scsi: lpfc: Replace io_channels for nvme and fcp with general hdw_queues per cpu") has introduced static checker warnings for potential null dereferences in 'lpfc_sli4_hba_unset()' and commit 1ffdd2c0440d ("scsi: lpfc: resolve static checker warning in lpfc_sli4_hba_unset") has tried to fix it. However, yet another potential null dereference is remaining. This commit fixes it.

This bug was discovered and resolved using Coverity Static Analysis Security Testing (SAST) by Synopsys, Inc.

Fixes 1ffdd2c0440d ("scsi: lpfc: resolve static checker warning inlpfc_sli4_hba_unset")
Fixes cdb42becdd40 ("scsi: lpfc: Replace io_channels for nvme and fcp with general hdw_queues per cpu")
---
  drivers/scsi/lpfc/lpfc_init.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/scsi/lpfc/lpfc_init.c +0 -0
index 69a5249e007a..6637f84a3d1b 100644

drivers/scsi/lpfc/lpfc_init.c lpfc_sli4_hba_unset(struct lpfc_hba *phba) · line 11885

Quoted 9 lines
drivers/scsi/lpfc/lpfc_init.c +2 -1
@@ -11878,7 +11878,8 @@ lpfc_sli4_hba_unset(struct lpfc_hba *phba)
  	lpfc_sli4_xri_exchange_busy_wait(phba);
 
  	/* per-phba callback de-registration for hotplug event */
-	lpfc_cpuhp_remove(phba);
+	if (phba->pport)
+		lpfc_cpuhp_remove(phba);
 
  	/* Disable PCI subsystem interrupt */
  	lpfc_sli4_disable_intr(phba);

-- james

#2 lore raw
In reply to SeongJae Park
Quoted 8 lines · SeongJae Park

Commit cdb42becdd40 ("scsi: lpfc: Replace io_channels for nvme and fcp with general hdw_queues per cpu") has introduced static checker warnings for potential null dereferences in 'lpfc_sli4_hba_unset()' and commit 1ffdd2c0440d ("scsi: lpfc: resolve static checker warning in lpfc_sli4_hba_unset") has tried to fix it. However, yet another potential null dereference is remaining. This commit fixes it.

[...]

Applied to 5.8/scsi-fixes, thanks!

[1/1] scsi: lpfc: Avoid another null dereference in lpfc_sli4_hba_unset()

      https://git.kernel.org/mkp/scsi/c/46da547e21d6
Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering