[MTD] OneNAND: Free the bad block table when the device is released

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Fri Feb 9 09:59:03 EST 2007


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=f00b0046d2eafac3e78e8def9374c7492820a9d2
Commit:     f00b0046d2eafac3e78e8def9374c7492820a9d2
Parent:     75384b0d9c04dc2d48f45825f84a982eaf5c2f53
Author:     Adrian Hunter <[ext-adrian.hunter at nokia.com]>
AuthorDate: Mon Jan 22 17:01:01 2007 +0900
Committer:  Kyungmin Park <kyungmin.park at samsung.com>
CommitDate: Mon Jan 22 21:27:56 2007 +0900

    [MTD] OneNAND: Free the bad block table when the device is released
    
    OneNAND does 2 memory allocations for bad block information.
    Only one of them was being freed.
    
    Signed-off-by: Adrian Hunter <ext-adrian.hunter at nokia.com>
    Signed-off-by: Kyungmin Park <kyungmin.park at samsung.com>
---
 drivers/mtd/onenand/onenand_base.c |    5 ++++-
 drivers/mtd/onenand/onenand_bbt.c  |    4 ++--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/onenand/onenand_base.c b/drivers/mtd/onenand/onenand_base.c
index 0ade237..0249b4a 100644
--- a/drivers/mtd/onenand/onenand_base.c
+++ b/drivers/mtd/onenand/onenand_base.c
@@ -2133,8 +2133,11 @@ void onenand_release(struct mtd_info *mtd)
 	del_mtd_device (mtd);
 
 	/* Free bad block table memory, if allocated */
-	if (this->bbm)
+	if (this->bbm) {
+		struct bbm_info *bbm = this->bbm;
+		kfree(bbm->bbt);
 		kfree(this->bbm);
+	}
 	/* Buffer allocated by onenand_scan */
 	if (this->options & ONENAND_PAGEBUF_ALLOC)
 		kfree(this->page_buf);
diff --git a/drivers/mtd/onenand/onenand_bbt.c b/drivers/mtd/onenand/onenand_bbt.c
index 98f8fd1..90db8f5 100644
--- a/drivers/mtd/onenand/onenand_bbt.c
+++ b/drivers/mtd/onenand/onenand_bbt.c
@@ -168,8 +168,8 @@ static int onenand_isbad_bbt(struct mtd_info *mtd, loff_t offs, int allowbbt)
  * marked good / bad blocks and writes the bad block table(s) to
  * the selected place.
  *
- * The bad block table memory is allocated here. It must be freed
- * by calling the onenand_free_bbt function.
+ * The bad block table memory is allocated here. It is freed
+ * by the onenand_release function.
  *
  */
 int onenand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd)



More information about the linux-mtd-cvs mailing list