mtd: nandsim: fix free of NULL pointer
Linux-MTD Mailing List
linux-mtd at lists.infradead.org
Tue Sep 1 14:59:01 PDT 2015
Gitweb: http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=ec7478fa173f65e5ee5fd2ba42c59ca3e700027b
Commit: ec7478fa173f65e5ee5fd2ba42c59ca3e700027b
Parent: 83dcf400be7165af938dbd6b8ce6805c754701db
Author: shengyong <shengyong1 at huawei.com>
AuthorDate: Thu Jun 25 02:23:13 2015 +0000
Committer: Brian Norris <computersforpeace at gmail.com>
CommitDate: Mon Jul 6 15:20:09 2015 -0700
mtd: nandsim: fix free of NULL pointer
If allocating ns->nand_pages_slab fails, do not try to destroy it when
cleaning up nandsim resources.
Signed-off-by: Sheng Yong <shengyong1 at huawei.com>
Signed-off-by: Brian Norris <computersforpeace at gmail.com>
---
drivers/mtd/nand/nandsim.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/mtd/nand/nandsim.c b/drivers/mtd/nand/nandsim.c
index 52c0c1a..6a74f62 100644
--- a/drivers/mtd/nand/nandsim.c
+++ b/drivers/mtd/nand/nandsim.c
@@ -649,7 +649,8 @@ static void free_device(struct nandsim *ns)
kmem_cache_free(ns->nand_pages_slab,
ns->pages[i].byte);
}
- kmem_cache_destroy(ns->nand_pages_slab);
+ if (ns->nand_pages_slab)
+ kmem_cache_destroy(ns->nand_pages_slab);
vfree(ns->pages);
}
}
More information about the linux-mtd-cvs
mailing list