aboutsummaryrefslogtreecommitdiff
path: root/drivers/dfu/dfu_mmc.c
diff options
context:
space:
mode:
authorMasami Hiramatsu2022-01-31 11:52:29 +0900
committerTom Rini2022-02-11 11:29:23 -0500
commit8db74c153b4e30edc5290da6c7330c63558678d0 (patch)
treee98f5ce256899d325e30abf32939a0d5ac8cc72c /drivers/dfu/dfu_mmc.c
parentd8ae90a8d47da2f22041bf9f6fd6d42a598f44ee (diff)
DFU: Accept redundant spaces and tabs in dfu_alt_info
If dfu_alt_info has repeated spaces or tab (for indentation or readability), the dfu fails to parse it. For example, if dfu_alt_info="mtd nor1=image raw 100000 200000" (double spaces after "raw"), the image entity start address is '0' and the size '0x100000'. This is because the repeated space is not skipped. Use space and tab as a separater and apply skip_spaces() to skip redundant spaces and tabs. Signed-off-by: Masami Hiramatsu <masami.hiramatsu@linaro.org>
Diffstat (limited to 'drivers/dfu/dfu_mmc.c')
-rw-r--r--drivers/dfu/dfu_mmc.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/drivers/dfu/dfu_mmc.c b/drivers/dfu/dfu_mmc.c
index 3dab5a5f633..d747ede66c4 100644
--- a/drivers/dfu/dfu_mmc.c
+++ b/drivers/dfu/dfu_mmc.c
@@ -351,11 +351,12 @@ int dfu_fill_entity_mmc(struct dfu_entity *dfu, char *devstr, char *s)
dfu->data.mmc.dev_num = dectoul(devstr, NULL);
for (; parg < argv + sizeof(argv) / sizeof(*argv); ++parg) {
- *parg = strsep(&s, " ");
+ *parg = strsep(&s, " \t");
if (*parg == NULL) {
pr_err("Invalid number of arguments.\n");
return -ENODEV;
}
+ s = skip_spaces(s);
}
entity_type = argv[0];
@@ -390,9 +391,11 @@ int dfu_fill_entity_mmc(struct dfu_entity *dfu, char *devstr, char *s)
* specifying the mmc HW defined partition number
*/
if (s)
- if (!strcmp(strsep(&s, " "), "mmcpart"))
+ if (!strcmp(strsep(&s, " \t"), "mmcpart")) {
+ s = skip_spaces(s);
dfu->data.mmc.hw_partition =
simple_strtoul(s, NULL, 0);
+ }
} else if (!strcmp(entity_type, "part")) {
struct disk_partition partinfo;
@@ -412,8 +415,10 @@ int dfu_fill_entity_mmc(struct dfu_entity *dfu, char *devstr, char *s)
* specifying the mmc HW defined partition number
*/
if (s)
- if (!strcmp(strsep(&s, " "), "offset"))
+ if (!strcmp(strsep(&s, " \t"), "offset")) {
+ s = skip_spaces(s);
offset = simple_strtoul(s, NULL, 0);
+ }
dfu->layout = DFU_RAW_ADDR;
dfu->data.mmc.lba_start = partinfo.start + offset;