Patch "mtd: parser: cmdline: Support MTD names containing one or more colons" 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: parser: cmdline: Support MTD names containing one or more colons

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-parser-cmdline-support-mtd-names-containing-one-.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 2658c3573a50def3a435b143aa80b95c1313b893
Author: Boris Brezillon <boris.brezillon@xxxxxxxxxxxxx>
Date:   Wed Apr 29 09:53:47 2020 -0700

    mtd: parser: cmdline: Support MTD names containing one or more colons
    
    [ Upstream commit eb13fa0227417e84aecc3bd9c029d376e33474d3 ]
    
    Looks like some drivers define MTD names with a colon in it, thus
    making mtdpart= parsing impossible. Let's fix the parser to gracefully
    handle that case: the last ':' in a partition definition sequence is
    considered instead of the first one.
    
    Signed-off-by: Boris Brezillon <boris.brezillon@xxxxxxxxxxxxx>
    Signed-off-by: Ron Minnich <rminnich@xxxxxxxxxx>
    Tested-by: Ron Minnich <rminnich@xxxxxxxxxx>
    Signed-off-by: Richard Weinberger <richard@xxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/mtd/parsers/cmdlinepart.c b/drivers/mtd/parsers/cmdlinepart.c
index c86f2db8c882d..0625b25620ca7 100644
--- a/drivers/mtd/parsers/cmdlinepart.c
+++ b/drivers/mtd/parsers/cmdlinepart.c
@@ -218,12 +218,29 @@ static int mtdpart_setup_real(char *s)
 		struct cmdline_mtd_partition *this_mtd;
 		struct mtd_partition *parts;
 		int mtd_id_len, num_parts;
-		char *p, *mtd_id;
+		char *p, *mtd_id, *semicol;
+
+		/*
+		 * Replace the first ';' by a NULL char so strrchr can work
+		 * properly.
+		 */
+		semicol = strchr(s, ';');
+		if (semicol)
+			*semicol = '\0';
 
 		mtd_id = s;
 
-		/* fetch <mtd-id> */
-		p = strchr(s, ':');
+		/*
+		 * fetch <mtd-id>. We use strrchr to ignore all ':' that could
+		 * be present in the MTD name, only the last one is interpreted
+		 * as an <mtd-id>/<part-definition> separator.
+		 */
+		p = strrchr(s, ':');
+
+		/* Restore the ';' now. */
+		if (semicol)
+			*semicol = ';';
+
 		if (!p) {
 			pr_err("no mtd-id\n");
 			return -EINVAL;



[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