linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] scsi: bnx2i: fix potential use after free
@ 2019-11-06 12:32 Pan Bian
  2019-11-19  5:06 ` Martin K. Petersen
  0 siblings, 1 reply; 2+ messages in thread
From: Pan Bian @ 2019-11-06 12:32 UTC (permalink / raw)
  To: QLogic-Storage-Upstream, James E.J. Bottomley, Martin K. Petersen
  Cc: linux-scsi, linux-kernel, Pan Bian

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")
Signed-off-by: Pan Bian <bianpan2016@163.com>
---
 drivers/scsi/bnx2i/bnx2i_iscsi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index c5fa5f3b00e9..0b28d44d3573 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -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);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] scsi: bnx2i: fix potential use after free
  2019-11-06 12:32 [PATCH] scsi: bnx2i: fix potential use after free Pan Bian
@ 2019-11-19  5:06 ` Martin K. Petersen
  0 siblings, 0 replies; 2+ messages in thread
From: Martin K. Petersen @ 2019-11-19  5:06 UTC (permalink / raw)
  To: Pan Bian
  Cc: QLogic-Storage-Upstream, James E.J. Bottomley,
	Martin K. Petersen, linux-scsi, linux-kernel


Pan,

> 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!

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-11-19  5:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-06 12:32 [PATCH] scsi: bnx2i: fix potential use after free Pan Bian
2019-11-19  5:06 ` Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).