linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] scsi: lpfc: Fix a use after free in lpfc_nvme_unsol_ls_handler()
@ 2020-05-12 18:19 Dan Carpenter
  2020-05-14 17:03 ` James Smart
  2020-05-15  0:21 ` Martin K. Petersen
  0 siblings, 2 replies; 14+ messages in thread
From: Dan Carpenter @ 2020-05-12 18:19 UTC (permalink / raw)
  To: James Smart
  Cc: Dick Kennedy, James E.J. Bottomley, Martin K. Petersen,
	Jens Axboe, Hannes Reinecke, Paul Ely, linux-scsi,
	kernel-janitors

The "axchg" pointer is dereferenced when we call the
lpfc_nvme_unsol_ls_issue_abort() function.  It can't be either freed or
NULL.

Fixes: 3a8070c567aa ("lpfc: Refactor NVME LS receive handling")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/scsi/lpfc/lpfc_sli.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index 38889cb6e1996..fcf51b4192d66 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -2895,14 +2895,14 @@ lpfc_nvme_unsol_ls_handler(struct lpfc_hba *phba, struct lpfc_iocbq *piocb)
 			(phba->nvmet_support) ? "T" : "I", ret);
 
 out_fail:
-	kfree(axchg);
-
 	/* recycle receive buffer */
 	lpfc_in_buf_free(phba, &nvmebuf->dbuf);
 
 	/* If start of new exchange, abort it */
-	if (fctl & FC_FC_FIRST_SEQ && !(fctl & FC_FC_EX_CTX))
+	if (axchg && (fctl & FC_FC_FIRST_SEQ) && !(fctl & FC_FC_EX_CTX))
 		lpfc_nvme_unsol_ls_issue_abort(phba, axchg, sid, oxid);
+
+	kfree(axchg);
 }
 
 /**
-- 
2.26.2


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

end of thread, other threads:[~2020-05-20 18:02 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-05-12 18:19 [PATCH] scsi: lpfc: Fix a use after free in lpfc_nvme_unsol_ls_handler() Dan Carpenter
2020-05-14 17:03 ` James Smart
2020-05-15  0:21 ` Martin K. Petersen
2020-05-15 10:19   ` [PATCH resend] " Dan Carpenter
2020-05-20 16:55     ` Christoph Hellwig
2020-05-20 17:24       ` Dan Carpenter
2020-05-20 17:28         ` Christoph Hellwig
2020-05-20 17:33           ` Martin K. Petersen
2020-05-20 17:37             ` Christoph Hellwig
2020-05-20 17:39               ` Martin K. Petersen
2020-05-20 17:48                 ` Christoph Hellwig
2020-05-20 17:51                   ` James Smart
2020-05-20 17:57                     ` Christoph Hellwig
2020-05-20 18:01                     ` Dan Carpenter

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).