From: Markus Elfring <Markus.Elfring@web.de>
To: linux-scsi@vger.kernel.org, kernel-janitors@vger.kernel.org,
Dick Kennedy <dick.kennedy@broadcom.com>,
James Smart <james.smart@broadcom.com>,
"James E. J. Bottomley" <jejb@linux.ibm.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH 1/4] scsi: lpfc: Improve exception handling in lpfc_rcv_plogi()
Date: Thu, 28 Dec 2023 18:22:01 +0100 [thread overview]
Message-ID: <562d25d9-9550-4dc2-a7d9-40af3109e3db@web.de> (raw)
In-Reply-To: <48a127e8-ca4f-4fc4-81b7-226080fba720@web.de>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 28 Dec 2023 17:00:07 +0100
The kfree() function was called in one case by the
lpfc_rcv_plogi() function during error handling
even if the passed variable contained a null pointer.
This issue was detected by using the Coccinelle software.
* Thus adjust jump targets.
* Delete three variable assignments and a repeated pointer check
which became unnecessary with this refactoring.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/scsi/lpfc/lpfc_nportdisc.c | 18 +++++++-----------
1 file changed, 7 insertions(+), 11 deletions(-)
diff --git a/drivers/scsi/lpfc/lpfc_nportdisc.c b/drivers/scsi/lpfc/lpfc_nportdisc.c
index d9074929fbab..2559f2ac7277 100644
--- a/drivers/scsi/lpfc/lpfc_nportdisc.c
+++ b/drivers/scsi/lpfc/lpfc_nportdisc.c
@@ -459,10 +459,6 @@ lpfc_rcv_plogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
ndlp->nlp_nvme_info &= ~NLP_NVME_NSLER;
ndlp->nlp_flag &= ~NLP_FIRSTBURST;
- login_mbox = NULL;
- link_mbox = NULL;
- save_iocb = NULL;
-
/* Check for Nport to NPort pt2pt protocol */
if ((vport->fc_flag & FC_PT2PT) &&
!(vport->fc_flag & FC_PT2PT_PLOGI)) {
@@ -509,7 +505,7 @@ lpfc_rcv_plogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
link_mbox = mempool_alloc(phba->mbox_mem_pool,
GFP_KERNEL);
if (!link_mbox)
- goto out;
+ goto reject_response;
lpfc_config_link(phba, link_mbox);
link_mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
link_mbox->vport = vport;
@@ -522,7 +518,7 @@ lpfc_rcv_plogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
rc = lpfc_sli_issue_mbox(phba, link_mbox, MBX_NOWAIT);
if (rc == MBX_NOT_FINISHED) {
mempool_free(link_mbox, phba->mbox_mem_pool);
- goto out;
+ goto reject_response;
}
}
@@ -540,11 +536,11 @@ lpfc_rcv_plogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
login_mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
if (!login_mbox)
- goto out;
+ goto reject_response;
save_iocb = kzalloc(sizeof(*save_iocb), GFP_KERNEL);
if (!save_iocb)
- goto out;
+ goto free_mempool;
/* Save info from cmd IOCB to be used in rsp after all mbox completes */
memcpy((uint8_t *)save_iocb, (uint8_t *)cmdiocb,
@@ -657,9 +653,9 @@ lpfc_rcv_plogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
return 1;
out:
kfree(save_iocb);
- if (login_mbox)
- mempool_free(login_mbox, phba->mbox_mem_pool);
-
+free_mempool:
+ mempool_free(login_mbox, phba->mbox_mem_pool);
+reject_response:
stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC;
stat.un.b.lsRjtRsnCodeExp = LSEXP_OUT_OF_RESOURCE;
lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL);
--
2.43.0
next prev parent reply other threads:[~2023-12-28 17:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-28 17:20 [PATCH 0/4] scsi: lpfc: Adjustments for two function implementations Markus Elfring
2023-12-28 17:22 ` Markus Elfring [this message]
2023-12-28 17:24 ` [PATCH 2/4] scsi: lpfc: Return directly after a failed kzalloc() in lpfc_sli_read_link_ste() Markus Elfring
2023-12-28 17:26 ` [PATCH 3/4] scsi: lpfc: Delete an unnecessary return statement " Markus Elfring
2023-12-28 17:28 ` [PATCH 4/4] scsi: lpfc: Delete an unnecessary variable initialisation " Markus Elfring
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=562d25d9-9550-4dc2-a7d9-40af3109e3db@web.de \
--to=markus.elfring@web.de \
--cc=dick.kennedy@broadcom.com \
--cc=james.smart@broadcom.com \
--cc=jejb@linux.ibm.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
/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