Re: [PATCH] scsi: lpfc: Fix ndlp reference leak in lpfc_nlp_reg_node()
From: Paul Ely
Date: Thu Sep 17 2026 - 15:56:12 EST
Hello Wentao,
Broadcom has already fixed this issue via an AI security scan. We
will be pushing the patch very soon.
BTW: using NVME_XPT_REGD is wrong for lpfc when in NVMET mode. As
you correctly noted, When in NVMET mode, lpfc does not register NVME
rports with the nvme transport. That flag is reserved for initiator
mode that does register nvme rports with the nvme_fc transport.
Thanks
On Thu, Sep 17, 2026 at 10:46 AM Wentao Liang <vulab@xxxxxxxxxxx> wrote:
>
> In the NVMET case the driver takes a node reference in
> lpfc_nlp_reg_node() because the target does not register rports, but
> lpfc_nlp_unreg_node() only releases that reference when the
> NVME_XPT_REGD flag is set, and the NVMET path never sets it, so the
> reference is leaked until the node is torn down.
>
> Set NVME_XPT_REGD when the reference is taken so the existing put in
> lpfc_nlp_unreg_node() balances it.
>
> Fixes: 0614568361b0 ("scsi: lpfc: Delay unregistering from transport until GIDFT or ADISC completes")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Wentao Liang <vulab@xxxxxxxxxxx>
> ---
> drivers/scsi/lpfc/lpfc_hbadisc.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c
> index f3a85f6c796e..9e920eaff9ef 100644
> --- a/drivers/scsi/lpfc/lpfc_hbadisc.c
> +++ b/drivers/scsi/lpfc/lpfc_hbadisc.c
> @@ -4664,9 +4664,15 @@ lpfc_nlp_reg_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
> }
> } else {
> /* Just take an NDLP ref count since the
> - * target does not register rports.
> + * target does not register rports. Mark it as
> + * an NVME transport ref so that
> + * lpfc_nlp_unreg_node() releases it.
> */
> lpfc_nlp_get(ndlp);
> +
> + spin_lock_irqsave(&ndlp->lock, iflags);
> + ndlp->fc4_xpt_flags |= NVME_XPT_REGD;
> + spin_unlock_irqrestore(&ndlp->lock, iflags);
> }
> }
> }
> --
> 2.34.1
>
Attachment:
smime.p7s
Description: S/MIME Cryptographic Signature