summaryrefslogtreecommitdiff
path: root/drivers/mtd
diff options
context:
space:
mode:
authorMiquel Raynal <miquel.raynal@bootlin.com>2020-05-25 10:58:43 +0200
committerMiquel Raynal <miquel.raynal@bootlin.com>2020-05-31 10:53:38 +0200
commit161246ec066f3eee40feeb02a07992db4c4e86f7 (patch)
treee142aa8b5fecde42628dce672e4799c7e405d908 /drivers/mtd
parent52bc51c54ef8d8e9358f12666e9f107d9a44f394 (diff)
mtd: rawnand: nandsim: Free the allocated device on error in ns_init()
The nandsim device is allocated and initialized inside ns_init() by a call to ns_alloc_device(), free it on error. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Link: https://lore.kernel.org/linux-mtd/20200525085851.17682-10-miquel.raynal@bootlin.com
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/nand/raw/nandsim.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/mtd/nand/raw/nandsim.c b/drivers/mtd/nand/raw/nandsim.c
index 53889bce81f1..d6e16ddb5de5 100644
--- a/drivers/mtd/nand/raw/nandsim.c
+++ b/drivers/mtd/nand/raw/nandsim.c
@@ -766,12 +766,14 @@ static int __init ns_init(struct mtd_info *mtd)
NS_ERR("init_nandsim: unable to allocate %u bytes for the internal buffer\n",
ns->geom.pgszoob);
ret = -ENOMEM;
- goto free_partition_names;
+ goto free_device;
}
memset(ns->buf.byte, 0xFF, ns->geom.pgszoob);
return 0;
+free_device:
+ ns_free_device(ns);
free_partition_names:
for (i = 0; i < ARRAY_SIZE(ns->partitions); ++i)
kfree(ns->partitions[i].name);