From patchwork Mon Aug 10 23:04:00 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: nand_update_bbt fix Date: Mon, 10 Aug 2009 13:04:00 -0000 From: Andrew McKay X-Patchwork-Id: 31111 Message-Id: <4A80A760.20901@iders.ca> To: linux-mtd@lists.infradead.org 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: Andrew McKay Iders Inc. 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; }