From: shengyong Date: Thu, 25 Jun 2015 02:23:13 +0000 (+0000) Subject: mtd: nandsim: fix free of NULL pointer X-Git-Tag: firefly_0821_release~176^2~766^2~218 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=ec7478fa173f65e5ee5fd2ba42c59ca3e700027b;p=firefly-linux-kernel-4.4.55.git 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 Signed-off-by: Brian Norris --- 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) 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); } }