mtd: nandsim: fix free of NULL pointer
authorshengyong <shengyong1@huawei.com>
Thu, 25 Jun 2015 02:23:13 +0000 (02:23 +0000)
committerBrian Norris <computersforpeace@gmail.com>
Mon, 6 Jul 2015 22:20:09 +0000 (15:20 -0700)
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>
drivers/mtd/nand/nandsim.c

index 52c0c1a3899cd1d09bd4d5d9685405be04deaab5..6a74f62a00337b6093ab1f43d8d441c0605b02c9 100644 (file)
@@ -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);
        }
 }