const char *type;
        int req_sg_cnt, rsp_sg_cnt;
        int rval =  (DID_ERROR << 16);
-       uint16_t nextlid = 0;
        uint32_t els_cmd = 0;
+       int qla_port_allocated = 0;
 
        if (bsg_request->msgcode == FC_BSG_RPT_ELS) {
                rport = fc_bsg_to_rport(bsg_job);
                /* make sure the rport is logged in,
                 * if not perform fabric login
                 */
-               if (qla2x00_fabric_login(vha, fcport, &nextlid)) {
+               if (atomic_read(&fcport->state) != FCS_ONLINE) {
                        ql_dbg(ql_dbg_user, vha, 0x7003,
-                           "Failed to login port %06X for ELS passthru.\n",
+                           "Port %06X is not online for ELS passthru.\n",
                            fcport->d_id.b24);
                        rval = -EIO;
                        goto done;
                        goto done;
                }
 
+               qla_port_allocated = 1;
                /* Initialize all required  fields of fcport */
                fcport->vha = vha;
                fcport->d_id.b.al_pa =
        goto done_free_fcport;
 
 done_free_fcport:
-       if (bsg_request->msgcode != FC_BSG_RPT_ELS)
+       if (qla_port_allocated)
                qla2x00_free_fcport(fcport);
 done:
        return rval;