Patch "mtd: parsers: afs: Fix freeing the part name memory in failure" has been added to the 5.4-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    mtd: parsers: afs: Fix freeing the part name memory in failure

to the 5.4-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     mtd-parsers-afs-fix-freeing-the-part-name-memory-in-.patch
and it can be found in the queue-5.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit f9d1483b2e80aa4f648d2bfdf1f7e88041f4d34d
Author: Manivannan Sadhasivam <manivannan.sadhasivam@xxxxxxxxxx>
Date:   Mon Jan 4 09:41:37 2021 +0530

    mtd: parsers: afs: Fix freeing the part name memory in failure
    
    [ Upstream commit 7b844cf445f0a7daa68be0ce71eb2c88d68b0c5d ]
    
    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@xxxxxxxxxx>
    Reviewed-by: Linus Walleij <linus.walleij@xxxxxxxxxx>
    Cc: Linus Walleij <linus.walleij@xxxxxxxxxx>
    Signed-off-by: Miquel Raynal <miquel.raynal@xxxxxxxxxxx>
    Link: https://lore.kernel.org/linux-mtd/20210104041137.113075-5-manivannan.sadhasivam@xxxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/mtd/parsers/afs.c b/drivers/mtd/parsers/afs.c
index 752b6cf005f71..8fd61767af831 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;



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux