diff options
author | Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> | 2021-01-04 05:11:37 +0100 |
---|---|---|
committer | Miquel Raynal <miquel.raynal@bootlin.com> | 2021-02-01 18:58:38 +0100 |
commit | 7b844cf445f0a7daa68be0ce71eb2c88d68b0c5d (patch) | |
tree | f91d0aab0f6e432c195653b7fd2be2a0dd70e0c5 /drivers/mtd | |
parent | mtd: parser: imagetag: fix error codes in bcm963xx_parse_imagetag_partitions() (diff) | |
download | linux-7b844cf445f0a7daa68be0ce71eb2c88d68b0c5d.tar.xz linux-7b844cf445f0a7daa68be0ce71eb2c88d68b0c5d.zip |
mtd: parsers: afs: Fix freeing the part name memory in failure
In the case of failure while parsing the partitions, the iterator should
be pre decremented by one before starting to free the memory allocated
by kstrdup(). Because in the failure case, kstrdup() will not succeed
and thus no memory will be allocated for the current iteration.
Fixes: 1fca1f6abb38 ("mtd: afs: simplify partition parsing")
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Cc: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210104041137.113075-5-manivannan.sadhasivam@linaro.org
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/parsers/afs.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/drivers/mtd/parsers/afs.c b/drivers/mtd/parsers/afs.c index 980e332bdac4..26116694c821 100644 --- a/drivers/mtd/parsers/afs.c +++ b/drivers/mtd/parsers/afs.c @@ -370,10 +370,8 @@ static int parse_afs_partitions(struct mtd_info *mtd, return i; out_free_parts: - while (i >= 0) { + while (--i >= 0) kfree(parts[i].name); - i--; - } kfree(parts); *pparts = NULL; return ret; |