scsi: lpfc: Add missing free iocb and nlp kref put for early return VMID cases
authorJames Smart <jsmart2021@gmail.com>
Sun, 11 Sep 2022 22:14:56 +0000 (15:14 -0700)
committerMartin K. Petersen <martin.petersen@oracle.com>
Fri, 16 Sep 2022 02:18:27 +0000 (22:18 -0400)
Sometimes VMID targets are not getting rediscovered after a port reset.

The iocb is not freed in lpfc_cmpl_ct_cmd_vmid(), which is the completion
function for the appid CT commands.  So after a port reset, the count of
sges is less than the expected count of 250.  This causes post reset
operation logic to fail and keep the port offline.

Fix by freeing the iocb and kref put for the lpfc_cmpl_ct_cmd_vmid() early
return cases.

Link: https://lore.kernel.org/r/20220911221505.117655-5-jsmart2021@gmail.com
Co-developed-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/lpfc/lpfc_ct.c

index b555ccb5ae3456c27f013949830359cf47e09efa..aad63adfc9ced736e9ce51c9c44078a49c5f1d59 100644 (file)
@@ -3909,6 +3909,7 @@ lpfc_cmpl_ct_cmd_vmid(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
        struct lpfc_sli_ct_request *ctrsp = outp->virt;
        u16 rsp = ctrsp->CommandResponse.bits.CmdRsp;
        struct app_id_object *app;
+       struct lpfc_nodelist *ndlp = cmdiocb->ndlp;
        u32 cmd, hash, bucket;
        struct lpfc_vmid *vmp, *cur;
        u8 *data = outp->virt;
@@ -3920,7 +3921,7 @@ lpfc_cmpl_ct_cmd_vmid(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
 
        if (lpfc_els_chk_latt(vport) || get_job_ulpstatus(phba, rspiocb)) {
                if (cmd != SLI_CTAS_DALLAPP_ID)
-                       return;
+                       goto free_res;
        }
        /* Check for a CT LS_RJT response */
        if (rsp == be16_to_cpu(SLI_CT_RESPONSE_FS_RJT)) {
@@ -3935,7 +3936,7 @@ lpfc_cmpl_ct_cmd_vmid(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
                        /* If DALLAPP_ID failed retry later */
                        if (cmd == SLI_CTAS_DALLAPP_ID)
                                vport->load_flag |= FC_DEREGISTER_ALL_APP_ID;
-                       return;
+                       goto free_res;
                }
        }
 
@@ -3949,7 +3950,7 @@ lpfc_cmpl_ct_cmd_vmid(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
                                 app->obj.entity_id_len);
 
                if (app->obj.entity_id_len == 0 || app->port_id == 0)
-                       return;
+                       goto free_res;
 
                hash = lpfc_vmid_hash_fn(app->obj.entity_id,
                                         app->obj.entity_id_len);
@@ -3996,6 +3997,9 @@ lpfc_cmpl_ct_cmd_vmid(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
                lpfc_printf_vlog(vport, KERN_DEBUG, LOG_DISCOVERY,
                                 "8857 Invalid command code\n");
        }
+free_res:
+       lpfc_ct_free_iocb(phba, cmdiocb);
+       lpfc_nlp_put(ndlp);
 }
 
 /**