if (info->lba_to_pba) kfree(info->lba_to_pba); if (info->pba_to_lba) kfree(info->pba_to_lba); 
kfree(info->lba_to_pba); kfree(info->pba_to_lba); 
static int sddr55_read_map(struct us_data *us) {	struct sddr55_card_info *info = (struct sddr55_card_info *)(us->extra);	int numblocks;	unsigned char *buffer;	unsigned char *command = us->iobuf;	int i;	unsigned short lba;	unsigned short max_lba;	int result;	if (!info->capacity)		return -1;	numblocks = info->capacity >> (info->blockshift + info->pageshift);		buffer = kmalloc( numblocks * 2, GFP_NOIO );		if (!buffer)		return -1;	memset(command, 0, 8);	command[5] = 0xB0;	command[6] = numblocks * 2 / 256;	command[7] = 0x8A;	result = sddr55_bulk_transport(us, DMA_TO_DEVICE, command, 8);	if ( result != USB_STOR_XFER_GOOD) {		kfree (buffer);		return -1;	}	result = sddr55_bulk_transport(us, DMA_FROM_DEVICE, buffer, numblocks * 2);	if ( result != USB_STOR_XFER_GOOD) {		kfree (buffer);		return -1;	}	result = sddr55_bulk_transport(us, DMA_FROM_DEVICE, command, 2);	if ( result != USB_STOR_XFER_GOOD) {		kfree (buffer);		return -1;	}	if (info->lba_to_pba)		kfree(info->lba_to_pba);	if (info->pba_to_lba)		kfree(info->pba_to_lba);	info->lba_to_pba = kmalloc(numblocks*sizeof(int), GFP_NOIO);	info->pba_to_lba = kmalloc(numblocks*sizeof(int), GFP_NOIO);	if (info->lba_to_pba == NULL || info->pba_to_lba == NULL) {		if (info->lba_to_pba != NULL)			kfree(info->lba_to_pba);		if (info->pba_to_lba != NULL)			kfree(info->pba_to_lba);		info->lba_to_pba = NULL;		info->pba_to_lba = NULL;		kfree(buffer);		return -1;	}	memset(info->lba_to_pba, 0xff, numblocks*sizeof(int));	memset(info->pba_to_lba, 0xff, numblocks*sizeof(int));	/* set maximum lba */	max_lba = info->max_log_blks;	if (max_lba > 1000)		max_lba = 1000;	// Each block is 64 bytes of control data, so block i is located in	// scatterlist block i*64/128k = i*(2^6)*(2^-17) = i*(2^-11)	for (i=0; i<numblocks; i++) {		int zone = i / 1024;		lba = short_pack(buffer[i * 2], buffer[i * 2 + 1]);			/* Every 1024 physical blocks ("zone"), the LBA numbers			 * go back to zero, but are within a higher			 * block of LBA's. Also, there is a maximum of			 * 1000 LBA's per zone. In other words, in PBA			 * 1024-2047 you will find LBA 0-999 which are			 * really LBA 1000-1999. Yes, this wastes 24			 * physical blocks per zone. Go figure. 			 * These devices can have blocks go bad, so there			 * are 24 spare blocks to use when blocks do go bad.			 */			/* SDDR55 returns 0xffff for a bad block, and 0x400 for the 			 * CIS block. (Is this true for cards 8MB or less??)			 * Record these in the physical to logical map			 */ 		info->pba_to_lba[i] = lba;		if (lba >= max_lba) {			continue;		}				if (info->lba_to_pba[lba + zone * 1000] != NOT_ALLOCATED &&		    !info->force_read_only) {			printk("sddr55: map inconsistency at LBA %04X\n", lba + zone * 1000);			info->force_read_only = 1;		}		if (lba<0x10 || (lba>=0x3E0 && lba<0x3EF))			US_DEBUGP("LBA %04X <-> PBA %04X\n", lba, i);		info->lba_to_pba[lba + zone * 1000] = i;	}	kfree(buffer);	return 0;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/1bc3c9e1e44c2059fe2ffa6ff70ad0a925d7b05f/sddr55.c/buggy/drivers/usb/storage/sddr55.c