public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Justin Tee <justintee8345@gmail.com>
To: linux-scsi@vger.kernel.org
Cc: jsmart2021@gmail.com, justin.tee@broadcom.com,
	Justin Tee <justintee8345@gmail.com>
Subject: [PATCH 02/10] lpfc: Reorder freeing of various dma buffers and their list removal
Date: Wed,  1 Mar 2023 15:16:18 -0800	[thread overview]
Message-ID: <20230301231626.9621-3-justintee8345@gmail.com> (raw)
In-Reply-To: <20230301231626.9621-1-justintee8345@gmail.com>

Code sections where dma resources are freed before list removal are
reworked to ensure item removal before freed.

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
---
 drivers/scsi/lpfc/lpfc_bsg.c | 2 +-
 drivers/scsi/lpfc/lpfc_ct.c  | 2 +-
 drivers/scsi/lpfc/lpfc_sli.c | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_bsg.c b/drivers/scsi/lpfc/lpfc_bsg.c
index 852b025e2fec..d8e86b468ef6 100644
--- a/drivers/scsi/lpfc/lpfc_bsg.c
+++ b/drivers/scsi/lpfc/lpfc_bsg.c
@@ -134,8 +134,8 @@ lpfc_free_bsg_buffers(struct lpfc_hba *phba, struct lpfc_dmabuf *mlist)
 	if (mlist) {
 		list_for_each_entry_safe(mlast, next_mlast, &mlist->list,
 					 list) {
-			lpfc_mbuf_free(phba, mlast->virt, mlast->phys);
 			list_del(&mlast->list);
+			lpfc_mbuf_free(phba, mlast->virt, mlast->phys);
 			kfree(mlast);
 		}
 		lpfc_mbuf_free(phba, mlist->virt, mlist->phys);
diff --git a/drivers/scsi/lpfc/lpfc_ct.c b/drivers/scsi/lpfc/lpfc_ct.c
index e941a99aa965..e290aff2e881 100644
--- a/drivers/scsi/lpfc/lpfc_ct.c
+++ b/drivers/scsi/lpfc/lpfc_ct.c
@@ -476,8 +476,8 @@ lpfc_free_ct_rsp(struct lpfc_hba *phba, struct lpfc_dmabuf *mlist)
 	struct lpfc_dmabuf *mlast, *next_mlast;
 
 	list_for_each_entry_safe(mlast, next_mlast, &mlist->list, list) {
-		lpfc_mbuf_free(phba, mlast->virt, mlast->phys);
 		list_del(&mlast->list);
+		lpfc_mbuf_free(phba, mlast->virt, mlast->phys);
 		kfree(mlast);
 	}
 	lpfc_mbuf_free(phba, mlist->virt, mlist->phys);
diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index c5b69f313af3..bfab1f0fb3f0 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -22329,10 +22329,10 @@ lpfc_free_sgl_per_hdwq(struct lpfc_hba *phba,
 	/* Free sgl pool */
 	list_for_each_entry_safe(list_entry, tmp,
 				 buf_list, list_node) {
+		list_del(&list_entry->list_node);
 		dma_pool_free(phba->lpfc_sg_dma_buf_pool,
 			      list_entry->dma_sgl,
 			      list_entry->dma_phys_sgl);
-		list_del(&list_entry->list_node);
 		kfree(list_entry);
 	}
 
@@ -22479,10 +22479,10 @@ lpfc_free_cmd_rsp_buf_per_hdwq(struct lpfc_hba *phba,
 	list_for_each_entry_safe(list_entry, tmp,
 				 buf_list,
 				 list_node) {
+		list_del(&list_entry->list_node);
 		dma_pool_free(phba->lpfc_cmd_rsp_buf_pool,
 			      list_entry->fcp_cmnd,
 			      list_entry->fcp_cmd_rsp_dma_handle);
-		list_del(&list_entry->list_node);
 		kfree(list_entry);
 	}
 
-- 
2.38.0


  parent reply	other threads:[~2023-03-01 23:07 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-01 23:16 [PATCH 00/10] lpfc: Update lpfc to revision 14.2.0.11 Justin Tee
2023-03-01 23:16 ` [PATCH 01/10] lpfc: Protect against potential lpfc_debugfs_lockstat_write buffer overflow Justin Tee
2023-03-01 23:16 ` Justin Tee [this message]
2023-03-01 23:16 ` [PATCH 03/10] lpfc: Fix lockdep warning for rx_monitor lock when unloading driver Justin Tee
2023-03-01 23:16 ` [PATCH 04/10] lpfc: Record LOGO state with discovery engine even if aborted Justin Tee
2023-03-01 23:16 ` [PATCH 05/10] lpfc: Defer issuing new PLOGI if received RSCN before completing REG_LOGIN Justin Tee
2023-03-01 23:16 ` [PATCH 06/10] lpfc: Correct used_rpi count when devloss tmo fires with no recovery Justin Tee
2023-03-01 23:16 ` [PATCH 07/10] lpfc: Skip waiting for register ready bits when in unrecoverable state Justin Tee
2023-03-01 23:16 ` [PATCH 08/10] lpfc: Revise lpfc_error_lost_link reason code evaluation logic Justin Tee
2023-03-01 23:16 ` [PATCH 09/10] lpfc: Update lpfc version to 14.2.0.11 Justin Tee
2023-03-01 23:16 ` [PATCH 10/10] lpfc: Copyright updates for 14.2.0.11 patches Justin Tee
2023-03-07  3:04 ` [PATCH 00/10] lpfc: Update lpfc to revision 14.2.0.11 Martin K. Petersen
2023-03-10  3:14 ` Martin K. Petersen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230301231626.9621-3-justintee8345@gmail.com \
    --to=justintee8345@gmail.com \
    --cc=jsmart2021@gmail.com \
    --cc=justin.tee@broadcom.com \
    --cc=linux-scsi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox