scsi: lpfc: Fix ioremap issues in lpfc_sli4_pci_mem_setup()
[ Upstream commit91a0c0c141
] When if_type equals zero and pci_resource_start(pdev, PCI_64BIT_BAR4) returns false, drbl_regs_memmap_p is not remapped. This passes a NULL pointer to iounmap(), which can trigger a WARN() on certain arches. When if_type equals six and pci_resource_start(pdev, PCI_64BIT_BAR4) returns true, drbl_regs_memmap_p may has been remapped and ctrl_regs_memmap_p is not remapped. This is a resource leak and passes a NULL pointer to iounmap(). To fix these issues, we need to add null checks before iounmap(), and change some goto labels. Fixes:1351e69fc6
("scsi: lpfc: Add push-to-adapter support to sli4") Signed-off-by: Shuchang Li <lishuchang@hust.edu.cn> Link: https://lore.kernel.org/r/20230404072133.1022-1-lishuchang@hust.edu.cn Reviewed-by: Justin Tee <justin.tee@broadcom.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
b2f423fda6
commit
bab8dc38b1
@ -10477,7 +10477,7 @@ lpfc_sli4_pci_mem_setup(struct lpfc_hba *phba)
|
|||||||
goto out_iounmap_all;
|
goto out_iounmap_all;
|
||||||
} else {
|
} else {
|
||||||
error = -ENOMEM;
|
error = -ENOMEM;
|
||||||
goto out_iounmap_all;
|
goto out_iounmap_ctrl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -10495,7 +10495,7 @@ lpfc_sli4_pci_mem_setup(struct lpfc_hba *phba)
|
|||||||
dev_err(&pdev->dev,
|
dev_err(&pdev->dev,
|
||||||
"ioremap failed for SLI4 HBA dpp registers.\n");
|
"ioremap failed for SLI4 HBA dpp registers.\n");
|
||||||
error = -ENOMEM;
|
error = -ENOMEM;
|
||||||
goto out_iounmap_ctrl;
|
goto out_iounmap_all;
|
||||||
}
|
}
|
||||||
phba->pci_bar4_memmap_p = phba->sli4_hba.dpp_regs_memmap_p;
|
phba->pci_bar4_memmap_p = phba->sli4_hba.dpp_regs_memmap_p;
|
||||||
}
|
}
|
||||||
@ -10520,9 +10520,11 @@ lpfc_sli4_pci_mem_setup(struct lpfc_hba *phba)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
out_iounmap_all:
|
out_iounmap_all:
|
||||||
iounmap(phba->sli4_hba.drbl_regs_memmap_p);
|
if (phba->sli4_hba.drbl_regs_memmap_p)
|
||||||
|
iounmap(phba->sli4_hba.drbl_regs_memmap_p);
|
||||||
out_iounmap_ctrl:
|
out_iounmap_ctrl:
|
||||||
iounmap(phba->sli4_hba.ctrl_regs_memmap_p);
|
if (phba->sli4_hba.ctrl_regs_memmap_p)
|
||||||
|
iounmap(phba->sli4_hba.ctrl_regs_memmap_p);
|
||||||
out_iounmap_conf:
|
out_iounmap_conf:
|
||||||
iounmap(phba->sli4_hba.conf_regs_memmap_p);
|
iounmap(phba->sli4_hba.conf_regs_memmap_p);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user