Commit 72e840a1 authored by Miquel Raynal's avatar Miquel Raynal

mtd: rawnand: nandsim: Free the partition names in ns_free()

ns_free() is the helper that is called symmetrically to ns_init() and
so should free the same objects, including the partition names.

Now, callers of ns_free() do not need to free this partition names
themselves.
Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200525085851.17682-11-miquel.raynal@bootlin.com
parent 161246ec
...@@ -786,6 +786,11 @@ static int __init ns_init(struct mtd_info *mtd) ...@@ -786,6 +786,11 @@ static int __init ns_init(struct mtd_info *mtd)
*/ */
static void ns_free(struct nandsim *ns) static void ns_free(struct nandsim *ns)
{ {
int i;
for (i = 0; i < ARRAY_SIZE(ns->partitions); ++i)
kfree(ns->partitions[i].name);
kfree(ns->buf.byte); kfree(ns->buf.byte);
ns_free_device(ns); ns_free_device(ns);
...@@ -2270,7 +2275,7 @@ static int __init ns_init_module(void) ...@@ -2270,7 +2275,7 @@ static int __init ns_init_module(void)
{ {
struct nand_chip *chip; struct nand_chip *chip;
struct nandsim *ns; struct nandsim *ns;
int ret, i; int ret;
if (bus_width != 8 && bus_width != 16) { if (bus_width != 8 && bus_width != 16) {
NS_ERR("wrong bus width (%d), use only 8 or 16\n", bus_width); NS_ERR("wrong bus width (%d), use only 8 or 16\n", bus_width);
...@@ -2402,8 +2407,6 @@ static int __init ns_init_module(void) ...@@ -2402,8 +2407,6 @@ static int __init ns_init_module(void)
err_exit: err_exit:
ns_free(ns); ns_free(ns);
nand_release(chip); nand_release(chip);
for (i = 0;i < ARRAY_SIZE(ns->partitions); ++i)
kfree(ns->partitions[i].name);
error: error:
kfree(ns); kfree(ns);
ns_free_lists(); ns_free_lists();
...@@ -2420,13 +2423,10 @@ static void __exit ns_cleanup_module(void) ...@@ -2420,13 +2423,10 @@ static void __exit ns_cleanup_module(void)
{ {
struct nand_chip *chip = mtd_to_nand(nsmtd); struct nand_chip *chip = mtd_to_nand(nsmtd);
struct nandsim *ns = nand_get_controller_data(chip); struct nandsim *ns = nand_get_controller_data(chip);
int i;
ns_debugfs_remove(ns); ns_debugfs_remove(ns);
ns_free(ns); /* Free nandsim private resources */ ns_free(ns); /* Free nandsim private resources */
nand_release(chip); /* Unregister driver */ nand_release(chip); /* Unregister driver */
for (i = 0;i < ARRAY_SIZE(ns->partitions); ++i)
kfree(ns->partitions[i].name);
kfree(ns); /* Free other structures */ kfree(ns); /* Free other structures */
ns_free_lists(); ns_free_lists();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment