From patchwork Mon Aug 10 23:04:00 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew McKay X-Patchwork-Id: 31111 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by bilbo.ozlabs.org (Postfix) with ESMTPS id 5FABEB7B68 for ; Tue, 11 Aug 2009 09:08:56 +1000 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1Maduj-00024x-Ky; Mon, 10 Aug 2009 23:04:25 +0000 Received: from koko.iders.ca ([206.45.72.61]) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1Maduc-00023u-Dt for linux-mtd@lists.infradead.org; Mon, 10 Aug 2009 23:04:22 +0000 Received: from [200.123.101.231] (zen.iders.ca [200.123.101.231]) by koko.iders.ca (Postfix) with ESMTP id 1166B3E400A for ; Mon, 10 Aug 2009 18:04:01 -0500 (CDT) Message-ID: <4A80A760.20901@iders.ca> Date: Mon, 10 Aug 2009 18:04:00 -0500 From: Andrew McKay User-Agent: Thunderbird 1.5.0.12 (X11/20071019) MIME-Version: 1.0 To: linux-mtd@lists.infradead.org Subject: nand_update_bbt fix X-Spam-Score: 0.0 (/) X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@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; }