if (new_fcport) kfree(new_fcport); 
kfree(new_fcport); 
qla2x00_configure_local_loop(scsi_qla_host_t *ha){	int		rval, rval2;	int		found_devs;	int		found;	fc_port_t	*fcport, *new_fcport;	uint16_t	index;	uint16_t	entries;	char		*id_iter;	uint16_t	loop_id;	uint8_t		domain, area, al_pa;	found_devs = 0;	new_fcport = NULL;	entries = MAX_FIBRE_DEVICES;	DEBUG3(printk("scsi(%ld): Getting FCAL position map\n", ha->host_no));	DEBUG3(qla2x00_get_fcal_position_map(ha, NULL));	/* Get list of logged in devices. */	memset(ha->gid_list, 0, GID_LIST_SIZE);	rval = qla2x00_get_id_list(ha, ha->gid_list, ha->gid_list_dma,	    &entries);	if (rval != QLA_SUCCESS)		goto cleanup_allocation;	DEBUG3(printk("scsi(%ld): Entries in ID list (%d)\n",	    ha->host_no, entries));	DEBUG3(qla2x00_dump_buffer((uint8_t *)ha->gid_list,	    entries * sizeof(struct gid_list_info)));	/* Allocate temporary fcport for any new fcports discovered. */	new_fcport = qla2x00_alloc_fcport(ha, GFP_KERNEL);	if (new_fcport == NULL) {		rval = QLA_MEMORY_ALLOC_FAILED;		goto cleanup_allocation;	}	new_fcport->flags &= ~FCF_FABRIC_DEVICE;	/*	 * Mark local devices that were present with FCF_DEVICE_LOST for now.	 */	list_for_each_entry(fcport, &ha->fcports, list) {		if (atomic_read(&fcport->state) == FCS_ONLINE &&		    fcport->port_type != FCT_BROADCAST &&		    (fcport->flags & FCF_FABRIC_DEVICE) == 0) {			DEBUG(printk("scsi(%ld): Marking port lost, "			    "loop_id=0x%04x\n",			    ha->host_no, fcport->loop_id));			atomic_set(&fcport->state, FCS_DEVICE_LOST);			fcport->flags &= ~FCF_FARP_DONE;		}	}	/* Add devices to port list. */	id_iter = (char *)ha->gid_list;	for (index = 0; index < entries; index++) {		domain = ((struct gid_list_info *)id_iter)->domain;		area = ((struct gid_list_info *)id_iter)->area;		al_pa = ((struct gid_list_info *)id_iter)->al_pa;		if (IS_QLA2100(ha) || IS_QLA2200(ha))			loop_id = (uint16_t)			    ((struct gid_list_info *)id_iter)->loop_id_2100;		else			loop_id = le16_to_cpu(			    ((struct gid_list_info *)id_iter)->loop_id);		id_iter += ha->gid_list_info_size;		/* Bypass reserved domain fields. */		if ((domain & 0xf0) == 0xf0)			continue;		/* Bypass if not same domain and area of adapter. */		if (area && domain &&		    (area != ha->d_id.b.area || domain != ha->d_id.b.domain))			continue;		/* Bypass invalid local loop ID. */		if (loop_id > LAST_LOCAL_LOOP_ID)			continue;		/* Fill in member data. */		new_fcport->d_id.b.domain = domain;		new_fcport->d_id.b.area = area;		new_fcport->d_id.b.al_pa = al_pa;		new_fcport->loop_id = loop_id;		rval2 = qla2x00_get_port_database(ha, new_fcport, 0);		if (rval2 != QLA_SUCCESS) {			DEBUG2(printk("scsi(%ld): Failed to retrieve fcport "			    "information -- get_port_database=%x, "			    "loop_id=0x%04x\n",			    ha->host_no, rval2, new_fcport->loop_id));			continue;		}		/* Check for matching device in port list. */		found = 0;		fcport = NULL;		list_for_each_entry(fcport, &ha->fcports, list) {			if (memcmp(new_fcport->port_name, fcport->port_name,			    WWN_SIZE))				continue;			fcport->flags &= ~(FCF_FABRIC_DEVICE |			    FCF_PERSISTENT_BOUND);			fcport->loop_id = new_fcport->loop_id;			fcport->port_type = new_fcport->port_type;			fcport->d_id.b24 = new_fcport->d_id.b24;			memcpy(fcport->node_name, new_fcport->node_name,			    WWN_SIZE);			found++;			break;		}		if (!found) {			/* New device, add to fcports list. */			new_fcport->flags &= ~FCF_PERSISTENT_BOUND;			list_add_tail(&new_fcport->list, &ha->fcports);			/* Allocate a new replacement fcport. */			fcport = new_fcport;			new_fcport = qla2x00_alloc_fcport(ha, GFP_KERNEL);			if (new_fcport == NULL) {				rval = QLA_MEMORY_ALLOC_FAILED;				goto cleanup_allocation;			}			new_fcport->flags &= ~FCF_FABRIC_DEVICE;		}		qla2x00_update_fcport(ha, fcport);		found_devs++;	}cleanup_allocation:	if (new_fcport)		kfree(new_fcport);	if (rval != QLA_SUCCESS) {		DEBUG2(printk("scsi(%ld): Configure local loop error exit: "		    "rval=%x\n", ha->host_no, rval));	}	if (found_devs) {		ha->device_flags |= DFLG_LOCAL_DEVICES;		ha->device_flags &= ~DFLG_RETRY_LOCAL_DEVICES;	}	return (rval);}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/c9475cb0c358ff0dd473544280d92482df491913/qla_init.c/buggy/drivers/scsi/qla2xxx/qla_init.c