c
// In lpfc_findnode_did
struct lpfc_nodelist *lpfc_findnode_did(struct lpfc_vport *vport, uint32_t did)
{
    struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
    struct lpfc_nodelist *ndlp;
    unsigned long iflags;

    spin_lock_irqsave(shost->host_lock, iflags);
    ndlp = __lpfc_findnode_did(vport, did);

    // Validate the resource before returning
    if (ndlp && ndlp->vport == vport && vport->port_state != LPFC_VPORT_DELETED) {
        // Resource is valid
    } else {
        ndlp = NULL; // or handle the error
    }

    spin_unlock_irqrestore(shost->host_lock, iflags);

    return ndlp;
}
