Skip to contentSkip to conversation

OneNAND: Free the bad block table when the device is released

PATCH In review Kyungmin Park 2 participants 2 messages Jan 22, 2007 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 OneNAND: Free the bad block table when the device is released

Hi Adrian,

See below comments.

Thank you,
Kyungmin Park

OneNAND does 2 memory allocations for bad block information. Only one of them was being freed.

---
 drivers/mtd/onenand/onenand_base.c |    6 +++++-
 drivers/mtd/onenand/onenand_bbt.c  |    4 ++--
 2 files changed, 7 insertions(+), 3 deletions(-)
drivers/mtd/onenand/onenand_base.c +5 -1
index 0ade237..38aa019 100644
@@ -2133,8 +2133,12 @@ #endif
 	del_mtd_device (mtd);
 
 	/* Free bad block table memory, if allocated */
-	if (this->bbm)
+	if (this->bbm) {
+		struct bbm_info *bbm = this->bbm;
+		if (bbm->bbt)
+			kfree(bbm->bbt);
 		kfree(this->bbm);
+	}
 

=> We just use kfree directly since the kfree also check the address.

           kfree(this->bbm->bbt);
           kfree(this->bbm);

/* Buffer allocated by onenand_scan */ if (this->options & ONENAND_PAGEBUF_ALLOC)
kfree(this->page_buf);

drivers/mtd/onenand/onenand_bbt.c +2 -2
index 98f8fd1..90db8f5 100644
@@ -168,8 +168,8 @@ static int onenand_isbad_bbt(struct mtd_
  * 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)
Signature · 1 line
1.4.3
#1 lore raw

OneNAND does 2 memory allocations for bad block information. Only one of them was being freed.

---

drivers/mtd/onenand/onenand_base.c |    6 +++++-
drivers/mtd/onenand/onenand_bbt.c  |    4 ++--
2 files changed, 7 insertions(+), 3 deletions(-)
drivers/mtd/onenand/onenand_base.c +0 -0
index 0ade237..38aa019 100644
@@ -2133,8 +2133,11 @@ #endif
	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);
drivers/mtd/onenand/onenand_bbt.c +2 -2
index 98f8fd1..90db8f5 100644
@@ -168,8 +168,8 @@ static int onenand_isbad_bbt(struct mtd_
 * 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)

Signature · 1 line
1.4.3