Skip to content

Commit 72e840a

Browse files
committed
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: Miquel Raynal <[email protected]> Link: https://lore.kernel.org/linux-mtd/[email protected]
1 parent 161246e commit 72e840a

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

drivers/mtd/nand/raw/nandsim.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,11 @@ static int __init ns_init(struct mtd_info *mtd)
786786
*/
787787
static void ns_free(struct nandsim *ns)
788788
{
789+
int i;
790+
791+
for (i = 0; i < ARRAY_SIZE(ns->partitions); ++i)
792+
kfree(ns->partitions[i].name);
793+
789794
kfree(ns->buf.byte);
790795
ns_free_device(ns);
791796

@@ -2270,7 +2275,7 @@ static int __init ns_init_module(void)
22702275
{
22712276
struct nand_chip *chip;
22722277
struct nandsim *ns;
2273-
int ret, i;
2278+
int ret;
22742279

22752280
if (bus_width != 8 && bus_width != 16) {
22762281
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)
24022407
err_exit:
24032408
ns_free(ns);
24042409
nand_release(chip);
2405-
for (i = 0;i < ARRAY_SIZE(ns->partitions); ++i)
2406-
kfree(ns->partitions[i].name);
24072410
error:
24082411
kfree(ns);
24092412
ns_free_lists();
@@ -2420,13 +2423,10 @@ static void __exit ns_cleanup_module(void)
24202423
{
24212424
struct nand_chip *chip = mtd_to_nand(nsmtd);
24222425
struct nandsim *ns = nand_get_controller_data(chip);
2423-
int i;
24242426

24252427
ns_debugfs_remove(ns);
24262428
ns_free(ns); /* Free nandsim private resources */
24272429
nand_release(chip); /* Unregister driver */
2428-
for (i = 0;i < ARRAY_SIZE(ns->partitions); ++i)
2429-
kfree(ns->partitions[i].name);
24302430
kfree(ns); /* Free other structures */
24312431
ns_free_lists();
24322432
}

0 commit comments

Comments
 (0)