Skip to content

Commit 64ef5f4

Browse files
Ansuelmiquelraynal
authored andcommitted
mtd: mtdpart: ignore error -ENOENT from parsers on subpartitions
Commit 5c2f772 ("mtd: mtdpart: check for subpartitions parsing result") introduced some kind of regression with parser on subpartitions where if a parser emits an error then the entire parsing process from the upper parser fails and partitions are deleted. Not checking for error in subpartitions was originally intended as special parser can emit error also in the case of the partition not correctly init (for example a wiped partition) or special case where the partition should be skipped due to some ENV variables externally provided (from bootloader for example) One example case is the TRX partition where, in the context of a wiped partition, returns a -ENOENT as the trx_magic is not found in the expected TRX header (as the partition is wiped) To better handle this and still keep some kind of error tracking (for example to catch -ENOMEM errors or -EINVAL errors), permit parser on subpartition to emit -ENOENT error, print a debug log and skip them accordingly. This results in giving better tracking of the status of the parser (instead of returning just 0, dropping any kind of signal that there is something wrong with the parser) and to some degree restore the original logic of the subpartitions parse. (worth to notice that some special partition might have all the special header present for the parser and declare 0 partition in it, this is why it would be wrong to simply return 0 in the case of a special partition that is NOT init for the scanning parser) Cc: stable@vger.kernel.org Fixes: 5c2f772 ("mtd: mtdpart: check for subpartitions parsing result") Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
1 parent a697c67 commit 64ef5f4

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

drivers/mtd/mtdpart.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,9 +425,12 @@ int add_mtd_partitions(struct mtd_info *parent,
425425

426426
mtd_add_partition_attrs(child);
427427

428-
/* Look for subpartitions */
428+
/* Look for subpartitions (skip if no maching parser found) */
429429
ret = parse_mtd_partitions(child, parts[i].types, NULL);
430-
if (ret < 0) {
430+
if (ret < 0 && ret == -ENOENT) {
431+
pr_debug("Skip parsing subpartitions: %d\n", ret);
432+
continue;
433+
} else if (ret < 0) {
431434
pr_err("Failed to parse subpartitions: %d\n", ret);
432435
goto err_del_partitions;
433436
}

0 commit comments

Comments
 (0)