From: James Smart <james.smart@broadcom.com>
To: Colin King <colin.king@canonical.com>,
Dick Kennedy <dick.kennedy@broadcom.com>,
"James E . J . Bottomley" <jejb@linux.ibm.com>,
"Martin K . Petersen" <martin.petersen@oracle.com>,
linux-scsi@vger.kernel.org
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH][next] scsi: lpfc: Fix memory leak on lcb_context
Date: Thu, 19 Nov 2020 12:58:59 -0800 [thread overview]
Message-ID: <fba5bb41-c193-d4a9-d85b-a13417150452@broadcom.com> (raw)
In-Reply-To: <20201118141314.462471-1-colin.king@canonical.com>
[-- Attachment #1: Type: text/plain, Size: 1661 bytes --]
On 11/18/2020 6:13 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Currently there is an error return path that neglects to free the
> allocation for lcb_context. Fix this by adding a new error free
> exit path that kfree's lcb_context before returning. Use this new
> kfree exit path in another exit error path that also kfree's the same
> object, allowing a line of code to be removed.
>
> Addresses-Coverity: ("Resource leak")
> Fixes: 4430f7fd09ec ("scsi: lpfc: Rework locations of ndlp reference taking")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> drivers/scsi/lpfc/lpfc_els.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
> index 03f47d1b21fe..0d3271b4c130 100644
> --- a/drivers/scsi/lpfc/lpfc_els.c
> +++ b/drivers/scsi/lpfc/lpfc_els.c
> @@ -6515,18 +6515,20 @@ lpfc_els_rcv_lcb(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
> lcb_context->ndlp = lpfc_nlp_get(ndlp);
> if (!lcb_context->ndlp) {
> rjt_err = LSRJT_UNABLE_TPC;
> - goto rjt;
> + goto rjt_free;
> }
>
> if (lpfc_sli4_set_beacon(vport, lcb_context, state)) {
> lpfc_printf_vlog(ndlp->vport, KERN_ERR, LOG_TRACE_EVENT,
> "0193 failed to send mail box");
> - kfree(lcb_context);
> lpfc_nlp_put(ndlp);
> rjt_err = LSRJT_UNABLE_TPC;
> - goto rjt;
> + goto rjt_free;
> }
> return 0;
> +
> +rjt_free:
> + kfree(lcb_context);
> rjt:
> memset(&stat, 0, sizeof(stat));
> stat.un.b.lsRjtRsnCode = rjt_err;
Looks good.
Reviewed-by: James Smart <james.smart@broadcom.com>
-- james
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4163 bytes --]
next prev parent reply other threads:[~2020-11-19 20:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-18 14:13 Colin King
2020-11-19 20:58 ` James Smart [this message]
2020-11-20 3:17 ` Martin K. Petersen
2020-11-24 3:57 ` 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=fba5bb41-c193-d4a9-d85b-a13417150452@broadcom.com \
--to=james.smart@broadcom.com \
--cc=colin.king@canonical.com \
--cc=dick.kennedy@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
all inboxes | Powered by JetHome®