]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
scsi: lpfc: Cleanup error exit paths in lpfc_fdmi_cmd() and associated messages
authorJustin Tee <justin.tee@broadcom.com>
Thu, 12 Feb 2026 21:30:02 +0000 (13:30 -0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 24 Feb 2026 18:06:52 +0000 (13:06 -0500)
Error labels in lpfc_fdmi_cmd() accidentally return success status and
can potentially leak memory.  Change error exit path status to return a
non-zero value using a common exit path for failure cases. The error
path also frees allocated memory and provides logging.

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Link: https://patch.msgid.link/20260212213008.149873-8-justintee8345@gmail.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/lpfc/lpfc_ct.c

index d64f4acfcdae9ff6778ffab6e4d8323dcf353efc..c7853e7fe0719e357f8d587f2027dd135dc389be 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************
  * This file is part of the Emulex Linux Device Driver for         *
  * Fibre Channel Host Bus Adapters.                                *
- * Copyright (C) 2017-2025 Broadcom. All Rights Reserved. The term *
+ * Copyright (C) 2017-2026 Broadcom. All Rights Reserved. The term *
  * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.     *
  * Copyright (C) 2004-2016 Emulex.  All rights reserved.           *
  * EMULEX and SLI are trademarks of Emulex.                        *
@@ -2427,13 +2427,14 @@ lpfc_cmpl_ct_disc_fdmi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
 
                        /* CGN is only for the physical port, no vports */
                        if (lpfc_fdmi_cmd(vport, ndlp, cmd,
-                                         LPFC_FDMI_VENDOR_ATTR_mi) == 0)
+                                         LPFC_FDMI_VENDOR_ATTR_mi) == 0) {
                                phba->link_flag |= LS_CT_VEN_RPA;
-                       lpfc_printf_log(phba, KERN_INFO,
+                               lpfc_printf_log(phba, KERN_INFO,
                                        LOG_DISCOVERY | LOG_ELS,
                                        "6458 Send MI FDMI:%x Flag x%x\n",
                                        phba->sli4_hba.pc_sli4_params.mi_ver,
                                        phba->link_flag);
+                       }
                } else {
                        lpfc_printf_log(phba, KERN_INFO,
                                        LOG_DISCOVERY | LOG_ELS,
@@ -3214,7 +3215,7 @@ lpfc_fdmi_cmd(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
                     struct lpfc_iocbq *rspiocb);
 
        if (!ndlp)
-               return 0;
+               goto fdmi_cmd_exit;
 
        cmpl = lpfc_cmpl_ct_disc_fdmi; /* called from discovery */
 
@@ -3320,7 +3321,7 @@ hba_out:
                if (vport->port_type != LPFC_PHYSICAL_PORT) {
                        ndlp = lpfc_findnode_did(phba->pport, FDMI_DID);
                        if (!ndlp)
-                               return 0;
+                               goto fdmi_cmd_free_rspvirt;
                }
                fallthrough;
        case SLI_MGMT_RPA:
@@ -3396,7 +3397,7 @@ port_out:
                if (vport->port_type != LPFC_PHYSICAL_PORT) {
                        ndlp = lpfc_findnode_did(phba->pport, FDMI_DID);
                        if (!ndlp)
-                               return 0;
+                               goto fdmi_cmd_free_rspvirt;
                }
                fallthrough;
        case SLI_MGMT_DPA: