scsi: lpfc: Add EDC ELS support
Hello James Smart,
The patch 9064aeb2df8e: "scsi: lpfc: Add EDC ELS support" from Aug 16, 2021 (linux-next), leads to the following Smatch static checker warning:
drivers/scsi/lpfc/lpfc_els.c:4353 lpfc_issue_els_edc() warn: missing unwind goto?
drivers/scsi/lpfc/lpfc_els.c
4290 int
4291 lpfc_issue_els_edc(struct lpfc_vport *vport, uint8_t retry)
4292 {
4293 struct lpfc_hba *phba = vport->phba;
4294 struct lpfc_iocbq *elsiocb;
4295 struct fc_els_edc *edc_req;
4296 struct fc_tlv_desc *tlv;
4297 u16 cmdsize;
4298 struct lpfc_nodelist *ndlp;
4299 u8 *pcmd = NULL;
4300 u32 cgn_desc_size, lft_desc_size;
4301 int rc;
4302
4303 if (vport->port_type == LPFC_NPIV_PORT)
4304 return -EACCES;
4305
4306 ndlp = lpfc_findnode_did(vport, Fabric_DID);
4307 if (!ndlp || ndlp->nlp_state != NLP_STE_UNMAPPED_NODE)
4308 return -ENODEV;
4309
4310 cgn_desc_size = (phba->cgn_init_reg_signal) ?
4311 sizeof(struct fc_diag_cg_sig_desc) : 0;
4312 lft_desc_size = (lpfc_link_is_lds_capable(phba)) ?
4313 sizeof(struct fc_diag_lnkflt_desc) : 0;
4314 cmdsize = cgn_desc_size + lft_desc_size;
4315
4316 /* Skip EDC if no applicable descriptors */
4317 if (!cmdsize)
4318 goto try_rdf;
4319
4320 cmdsize += sizeof(struct fc_els_edc);
4321 elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp,
4322 ndlp->nlp_DID, ELS_CMD_EDC);
4323 if (!elsiocb)
4324 goto try_rdf;
4325
4326 /* Configure the payload for the supported Diagnostics capabilities. */
4327 pcmd = (u8 *)elsiocb->cmd_dmabuf->virt;
4328 memset(pcmd, 0, cmdsize);
4329 edc_req = (struct fc_els_edc *)pcmd;
4330 edc_req->desc_len = cpu_to_be32(cgn_desc_size + lft_desc_size);
4331 edc_req->edc_cmd = ELS_EDC;
4332 tlv = edc_req->desc;
4333
4334 if (cgn_desc_size) {
4335 lpfc_format_edc_cgn_desc(phba, tlv);
4336 phba->cgn_sig_freq = lpfc_fabric_cgn_frequency;
4337 tlv = fc_tlv_next_desc(tlv);
4338 }
4339
4340 if (lft_desc_size)
4341 lpfc_format_edc_lft_desc(phba, tlv);
4342
4343 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS | LOG_CGN_MGMT,
4344 "4623 Xmit EDC to remote "
4345 "NPORT x%x reg_sig x%x reg_fpin:x%x\n",
4346 ndlp->nlp_DID, phba->cgn_reg_signal,
4347 phba->cgn_reg_fpin);
4348
4349 elsiocb->cmd_cmpl = lpfc_cmpl_els_disc_cmd;
4350 elsiocb->ndlp = lpfc_nlp_get(ndlp);
4351 if (!elsiocb->ndlp) {
4352 lpfc_els_free_iocb(phba, elsiocb);--> 4353 return -EIO;
This is a couple years old but apparently, but I've never reported it before. Smatch wanted a goto try_rdf; here. Not sure if Smatch is correct. If not just ignore this it. These are one time emails.
4354 }
4355
4356 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
4357 "Issue EDC: did:x%x refcnt %d",
4358 ndlp->nlp_DID, kref_read(&ndlp->kref), 0);
4359 rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0);
4360 if (rc == IOCB_ERROR) {
4361 /* The additional lpfc_nlp_put will cause the following
4362 * lpfc_els_free_iocb routine to trigger the rlease of
4363 * the node.
4364 */
4365 lpfc_els_free_iocb(phba, elsiocb);
4366 lpfc_nlp_put(ndlp);
4367 goto try_rdf;
4368 }
4369 return 0;
4370 try_rdf:
4371 phba->cgn_reg_fpin = LPFC_CGN_FPIN_WARN | LPFC_CGN_FPIN_ALARM;
4372 phba->cgn_reg_signal = EDC_CG_SIG_NOTSUPPORTED;
4373 rc = lpfc_issue_els_rdf(vport, 0);
4374 return rc;
4375 }regards,
dan carpenter
Hi Dan,
Quoted 4 lines · Dan Carpenter
This is a couple years old but apparently, but I've never reported it before. Smatch wanted a goto
try_rdf; here. Not sure if Smatch is correct. If not just ignore this it. These are one time emails.
I think return –EIO on line 4353 is fine. If lpfc_nlp_get(ndlp) from line 4350 returned NULL, then we want to early return and not issue an RDF. This behavior is consistent with the !ndlp check on lines 4307–4308. If we don’t have a valid ndlp login context with the Fabric, then there’s no point to goto try_rdf to issue an RDF.
And for line 4353, I confirm that the only unwind needed is lpfc_els_free_iocb from the previous line.
Regards,
Justin
Quoted 7 lines · Justin Tee
Hi Dan,
Quoted 4 lines · Dan Carpenter
This is a couple years old but apparently, but I've never reported it before. Smatch wanted a goto
try_rdf; here. Not sure if Smatch is correct. If not just ignore this it. These are one time emails.
Quoted 8 lines
I think return –EIO on line 4353 is fine. If
lpfc_nlp_get(ndlp)from line 4350 returned NULL, then we want to early return and not issue an RDF. This behavior is consistent with the !ndlp check on lines 4307–4308. If we don’t have a valid ndlp login context with the Fabric, then there’s no point to gototry_rdfto issue an RDF.And for line 4353, I confirm that the only unwind needed is
lpfc_els_free_iocbfrom the previous line.
Thanks, Justin!
regards,
dan carpenter