All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Smart <jsmart2021@gmail.com>
To: linux-scsi@vger.kernel.org
Cc: James Smart <jsmart2021@gmail.com>,
	stable@vger.kernel.org, Dick Kennedy <dick.kennedy@broadcom.com>
Subject: [PATCH 02/12] lpfc: Fix lpfc_io_buf resource leak in lpfc_get_scsi_buf_s4 error path
Date: Mon, 27 Jan 2020 16:23:02 -0800	[thread overview]
Message-ID: <20200128002312.16346-3-jsmart2021@gmail.com> (raw)
In-Reply-To: <20200128002312.16346-1-jsmart2021@gmail.com>

If a call to lpfc_get_cmd_rsp_buf_per_hdwq returns NULL (memory
allocation failure), a previously allocated lpfc_io_buf resource is
leaked.

Fix by releasing the lpfc_io_buf resource in the failure path.

Fixes: d79c9e9d4b3d ("scsi: lpfc: Support dynamic unbounded SGL lists on G7 hardware.")
Cc: <stable@vger.kernel.org> # v5.4+
Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
---
 drivers/scsi/lpfc/lpfc_scsi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
index 2c7e0b22db2f..96ac4a154c58 100644
--- a/drivers/scsi/lpfc/lpfc_scsi.c
+++ b/drivers/scsi/lpfc/lpfc_scsi.c
@@ -671,8 +671,10 @@ lpfc_get_scsi_buf_s4(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp,
 	lpfc_cmd->prot_data_type = 0;
 #endif
 	tmp = lpfc_get_cmd_rsp_buf_per_hdwq(phba, lpfc_cmd);
-	if (!tmp)
+	if (!tmp) {
+		lpfc_release_io_buf(phba, lpfc_cmd, lpfc_cmd->hdwq);
 		return NULL;
+	}
 
 	lpfc_cmd->fcp_cmnd = tmp->fcp_cmnd;
 	lpfc_cmd->fcp_rsp = tmp->fcp_rsp;
-- 
2.13.7


  parent reply	other threads:[~2020-01-28  0:23 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-28  0:23 [PATCH 00/12] lpfc: Update lpfc to revision 12.6.0.4 James Smart
2020-01-28  0:23 ` [PATCH 01/12] lpfc: Fix RQ buffer leakage when no IOCBs available James Smart
2020-01-28  0:23 ` James Smart [this message]
2020-01-28  0:23 ` [PATCH 03/12] lpfc: Fix broken Credit Recovery after driver load James Smart
2020-05-12 21:28   ` Chris Hofstaedtler
2020-05-12 23:59     ` James Smart
2020-05-13  7:47       ` Chris Hofstaedtler | Deduktiva
2020-05-13 10:25       ` Chris Hofstaedtler | Deduktiva
2020-01-28  0:23 ` [PATCH 04/12] lpfc: Fix registration of ELS type support in fdmi James Smart
2020-01-28  0:23 ` [PATCH 05/12] lpfc: Fix release of hwq to clear the eq relationship James Smart
2020-01-28  0:23 ` [PATCH 06/12] lpfc: Fix compiler warning on frame size James Smart
2020-01-28  0:23 ` [PATCH 07/12] lpfc: Fix coverity errors in fmdi attribute handling James Smart
2020-01-28  0:23 ` [PATCH 08/12] lpfc: Remove handler for obsolete ELS - Read Port Status (RPS) James Smart
2020-01-28  0:23 ` [PATCH 09/12] lpfc: Clean up hba max_lun_queue_depth checks James Smart
2020-01-28  0:23 ` [PATCH 10/12] lpfc: Change lpfc_lun_queue_depth attribute to writable James Smart
2020-01-28  0:23 ` [PATCH 11/12] lpfc: Update lpfc version to 12.6.0.4 James Smart
2020-01-28  0:23 ` [PATCH 12/12] lpfc: Copyright updates for 12.6.0.4 patches James Smart
2020-02-05  3:00 ` [PATCH 00/12] lpfc: Update lpfc to revision 12.6.0.4 Martin K. Petersen
2020-02-05 19:01   ` James Smart

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=20200128002312.16346-3-jsmart2021@gmail.com \
    --to=jsmart2021@gmail.com \
    --cc=dick.kennedy@broadcom.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=stable@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.