aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorshengyong <shengyong1@huawei.com>2015-06-24 22:23:13 -0400
committerBrian Norris <computersforpeace@gmail.com>2015-07-06 18:20:09 -0400
commitec7478fa173f65e5ee5fd2ba42c59ca3e700027b (patch)
tree438bfe81fa168f8fcea231bcf85e48cf03775589
parent83dcf400be7165af938dbd6b8ce6805c754701db (diff)
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@huawei.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
-rw-r--r--drivers/mtd/nand/nandsim.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/mtd/nand/nandsim.c b/drivers/mtd/nand/nandsim.c
index 52c0c1a3899c..6a74f62a0033 100644
--- a/drivers/mtd/nand/nandsim.c
+++ b/drivers/mtd/nand/nandsim.c
@@ -649,7 +649,8 @@ static void free_device(struct nandsim *ns)
649 kmem_cache_free(ns->nand_pages_slab, 649 kmem_cache_free(ns->nand_pages_slab,
650 ns->pages[i].byte); 650 ns->pages[i].byte);
651 } 651 }
652 kmem_cache_destroy(ns->nand_pages_slab); 652 if (ns->nand_pages_slab)
653 kmem_cache_destroy(ns->nand_pages_slab);
653 vfree(ns->pages); 654 vfree(ns->pages);
654 } 655 }
655} 656}