if (!td) return nand_memory_bbt(mtd, bd); 
if (!td) { if ((res = nand_memory_bbt(mtd, bd))) { printk (KERN_ERR "nand_bbt: Can't scan flash and build the RAM-based BBT\n"); kfree (this->bbt); this->bbt = NULL; } return res; } 
int nand_scan_bbt (struct mtd_info *mtd, struct nand_bbt_descr *bd){	struct nand_chip *this = mtd->priv;	int len, res = 0;	uint8_t *buf;	struct nand_bbt_descr *td = this->bbt_td;	struct nand_bbt_descr *md = this->bbt_md;	len = mtd->size >> (this->bbt_erase_shift + 2);	/* Allocate memory (2bit per block) */	this->bbt = kmalloc (len, GFP_KERNEL);	if (!this->bbt) {		printk (KERN_ERR "nand_scan_bbt: Out of memory\n");		return -ENOMEM;	}	/* Clear the memory bad block table */	memset (this->bbt, 0x00, len);	/* If no primary table decriptor is given, scan the device	 * to build a memory based bad block table	 */	if (!td)		return nand_memory_bbt(mtd, bd);	/* Allocate a temporary buffer for one eraseblock incl. oob */	len = (1 << this->bbt_erase_shift);	len += (len >> this->page_shift) * mtd->oobsize;	buf = kmalloc (len, GFP_KERNEL);	if (!buf) {		printk (KERN_ERR "nand_bbt: Out of memory\n");		kfree (this->bbt);		this->bbt = NULL;		return -ENOMEM;	}		/* Is the bbt at a given page ? */	if (td->options & NAND_BBT_ABSPAGE) {		res = read_abs_bbts (mtd, buf, td, md);	} else {			/* Search the bad block table using a pattern in oob */		res = search_read_bbts (mtd, buf, td, md);	}		if (res) 		res = check_create (mtd, buf, bd);		/* Prevent the bbt regions from erasing / writing */	mark_bbt_region (mtd, td);	if (md)		mark_bbt_region (mtd, md);		kfree (buf);	return res;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/eeada24da8bd23fcf6acd2729be054ea99b301bb/nand_bbt.c/buggy/drivers/mtd/nand/nand_bbt.c