Skip to contentSkip to conversation

scsi: bnx2i: fix potential use after free

PATCH Applied Pan Bian 2 participants 2 messages Nov 6, 2019 – Nov 19, 2019

Subsystems (2)
lore
Share & tools
lore

Pan Bian

author
#0 lore raw

PATCH 1/1 scsi: bnx2i: fix potential use after free

The membe hba->pcidev may be used after its reference is dropped. Move the put function to where it is never used to avoid potential use after free issues.

Fixes a77171806515 ("[SCSI] bnx2i: Removed the reference to the netdev->base_addr")
---
 drivers/scsi/bnx2i/bnx2i_iscsi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/bnx2i/bnx2i_iscsi.c +1 -1
index c5fa5f3b00e9..0b28d44d3573 100644
@@ -915,12 +915,12 @@ void bnx2i_free_hba(struct bnx2i_hba *hba)
 	INIT_LIST_HEAD(&hba->ep_ofld_list);
 	INIT_LIST_HEAD(&hba->ep_active_list);
 	INIT_LIST_HEAD(&hba->ep_destroy_list);
-	pci_dev_put(hba->pcidev);
 
 	if (hba->regview) {
 		pci_iounmap(hba->pcidev, hba->regview);
 		hba->regview = NULL;
 	}
+	pci_dev_put(hba->pcidev);
 	bnx2i_free_mp_bdt(hba);
 	bnx2i_release_free_cid_que(hba);
 	iscsi_host_free(shost);
Signature · 1 line
2.7.4
#1 lore raw

Pan,

Quoted 3 lines

The membe hba->pcidev may be used after its reference is dropped. Move the put function to where it is never used to avoid potential use after free issues.

Applied to 5.5/scsi-queue, thanks!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering