nand_update_bbt fix

Andrew McKay amckay at iders.ca
Mon Aug 10 19:04:00 EDT 2009


Hello,

For NAND parts with 2K pages or larger, kmalloc of one erase block will exceed 
128K and fail.  A vmalloc is used in nand_scan_bbt to allocate enough memory for 
one erase block.  This should likely be the case for nand_update_bbt as well.

Not sure the proper way to submit a patch, but here's a diff of the change:

diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c
index 55c23e5..43b8d08 100644
--- a/drivers/mtd/nand/nand_bbt.c
+++ b/drivers/mtd/nand/nand_bbt.c
@@ -1030,7 +1030,7 @@ int nand_update_bbt(struct mtd_info *mtd, loff_t offs)
   /* 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);
+ buf = vmalloc(len);
   if (!buf) {
     printk(KERN_ERR "nand_update_bbt: Out of memory\n");
     return -ENOMEM;
@@ -1063,7 +1063,7 @@ int nand_update_bbt(struct mtd_info *mtd, loff_t offs)
   }

   out:
- kfree(buf);
+ vfree(buf);
   return res;
  }

Andrew McKay
Iders Inc.



More information about the linux-mtd mailing list