{
        struct efc_nport *nport = arg;
 
+       nport->attaching = false;
        if (efc_nport_get_mbox_status(nport, mqe, status)) {
                efc_nport_free_resources(nport, EFC_EVT_NPORT_ATTACH_FAIL, mqe);
                return -EIO;
        if (rc) {
                efc_log_err(efc, "REG_VPI command failure\n");
                efc_nport_free_resources(nport, EFC_EVT_NPORT_ATTACH_FAIL, buf);
+       } else {
+               nport->attaching = true;
        }
 
        return rc;
        /* Issue the UNREG_VPI command to free the assigned VPI context */
        if (nport->attached)
                efc_nport_free_unreg_vpi(nport);
-       else
+       else if (nport->attaching)
                nport->free_req_pending = true;
+       else
+               efc_sm_post_event(&nport->sm, EFC_EVT_NPORT_FREE_OK, NULL);
 
        return 0;
 }