# Re: \[PATCH v4 4/4\] mtd: parsers: afs: Fix freeing the part name memory in failure

- From: Miquel Raynal \<miquel.raynal@bootlin.com\>
- Date: 2021-01-04 10:26:53 
- List: linux-devicetree
- Page: https://ratatoskr.run/linux-devicetree/2021/01/6222814
- Thread: https://ratatoskr.run/linux-devicetree/2021/01/6222638/t.md

```text
On Mon, 2021-01-04 at 04:11:37 UTC, Manivannan Sadhasivam wrote:
> 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 <redacted>
> Reviewed-by: Linus Walleij <redacted>
> Cc: Linus Walleij <redacted>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.

Miquel
```
