mtd: Blackfin NFC: fix invalid free in remove()

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Mon Sep 13 04:59:02 EDT 2010


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=8b865d5efd9205b131dd9a43a6f450c05d38aaa1
Commit:     8b865d5efd9205b131dd9a43a6f450c05d38aaa1
Parent:     eac15a429a27cb74115daaf4c1127c5e854d50e4
Author:     Mike Frysinger <vapier at gentoo.org>
AuthorDate: Sat Aug 28 16:42:04 2010 -0400
Committer:  David Woodhouse <David.Woodhouse at intel.com>
CommitDate: Mon Sep 13 08:49:03 2010 +0100

    mtd: Blackfin NFC: fix invalid free in remove()
    
    Since info->mtd isn't dynamically allocated, we shouldn't attempt to
    kfree() it.  Otherwise we get random fun corruption when unloading
    the driver built as a module.
    
    Signed-off-by: Mike Frysinger <vapier at gentoo.org>
    Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy at nokia.com>
    Signed-off-by: David Woodhouse <David.Woodhouse at intel.com>
---
 drivers/mtd/nand/bf5xx_nand.c |    7 +------
 1 files changed, 1 insertions(+), 6 deletions(-)

diff --git a/drivers/mtd/nand/bf5xx_nand.c b/drivers/mtd/nand/bf5xx_nand.c
index 162c5ea..6fbeefa 100644
--- a/drivers/mtd/nand/bf5xx_nand.c
+++ b/drivers/mtd/nand/bf5xx_nand.c
@@ -682,7 +682,6 @@ static int __devinit bf5xx_nand_add_partition(struct bf5xx_nand_info *info)
 static int __devexit bf5xx_nand_remove(struct platform_device *pdev)
 {
 	struct bf5xx_nand_info *info = to_nand_info(pdev);
-	struct mtd_info *mtd = NULL;
 
 	platform_set_drvdata(pdev, NULL);
 
@@ -690,11 +689,7 @@ static int __devexit bf5xx_nand_remove(struct platform_device *pdev)
 	 * and their partitions, then go through freeing the
 	 * resources used
 	 */
-	mtd = &info->mtd;
-	if (mtd) {
-		nand_release(mtd);
-		kfree(mtd);
-	}
+	nand_release(&info->mtd);
 
 	peripheral_free_list(bfin_nfc_pin_req);
 	bf5xx_nand_dma_remove(info);



More information about the linux-mtd-cvs mailing list