Skip to content

Commit eb13fa0

Browse files
bbrezillonrichardweinberger
authored andcommitted
mtd: parser: cmdline: Support MTD names containing one or more colons
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 <[email protected]> Signed-off-by: Ron Minnich <[email protected]> Tested-by: Ron Minnich <[email protected]> Signed-off-by: Richard Weinberger <[email protected]>
1 parent 9029537 commit eb13fa0

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

drivers/mtd/parsers/cmdlinepart.c

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,12 +226,29 @@ static int mtdpart_setup_real(char *s)
226226
struct cmdline_mtd_partition *this_mtd;
227227
struct mtd_partition *parts;
228228
int mtd_id_len, num_parts;
229-
char *p, *mtd_id;
229+
char *p, *mtd_id, *semicol;
230+
231+
/*
232+
* Replace the first ';' by a NULL char so strrchr can work
233+
* properly.
234+
*/
235+
semicol = strchr(s, ';');
236+
if (semicol)
237+
*semicol = '\0';
230238

231239
mtd_id = s;
232240

233-
/* fetch <mtd-id> */
234-
p = strchr(s, ':');
241+
/*
242+
* fetch <mtd-id>. We use strrchr to ignore all ':' that could
243+
* be present in the MTD name, only the last one is interpreted
244+
* as an <mtd-id>/<part-definition> separator.
245+
*/
246+
p = strrchr(s, ':');
247+
248+
/* Restore the ';' now. */
249+
if (semicol)
250+
*semicol = ';';
251+
235252
if (!p) {
236253
pr_err("no mtd-id\n");
237254
return -EINVAL;

0 commit comments

Comments
 (0)