summaryrefslogtreecommitdiffstats
path: root/target
diff options
context:
space:
mode:
authorJohn Thomson <git@johnthomson.fastmail.com.au>2024-10-16 07:13:25 +1000
committerRobert Marko <robimarko@gmail.com>2024-10-30 11:15:34 +0100
commitade045084bd3f86969eaf0b35234aaa01e430fe1 (patch)
tree6b101adfc3bcbe797fb19cad7a1f75e9f1967a51 /target
parenta6a44f94bf8ccae8c7843ac3db2d606b961976c2 (diff)
downloadopenwrt-ade045084bd3f86969eaf0b35234aaa01e430fe1.tar.gz
openwrt-ade045084bd3f86969eaf0b35234aaa01e430fe1.tar.bz2
openwrt-ade045084bd3f86969eaf0b35234aaa01e430fe1.zip
kernel: mtdsplit_minor: return 0 if not fatal
Introduced with Linux 6.7, in commit: 5c2f7727d437 ("mtd: mtdpart: check for subpartitions parsing result"), when a parser returns an error, this will be passed up, and consequently, all parent mtd partitions get torn down. Adjust the MiNOR mtdsplit driver to only return an error if there is a critical problem in reading from the mtd device or allocating memory. Otherwise return 0 to indicate that no partitions were found. Also add logging to indicate what went wrong. This mtdsplit parser makes a very limited check of the first YAFFS header. For example, this will not match expectations when initially booting an initramfs image with OEM on MTD. Signed-off-by: John Thomson <git@johnthomson.fastmail.com.au> Acked-by: Thibaut VARENE <hacks@slashdirt.org> Link: https://github.com/openwrt/openwrt/pull/16780 Signed-off-by: Robert Marko <robimarko@gmail.com>
Diffstat (limited to 'target')
-rw-r--r--target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_minor.c44
1 files changed, 29 insertions, 15 deletions
diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_minor.c b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_minor.c
index af6822e11a..be69de5798 100644
--- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_minor.c
+++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_minor.c
@@ -61,29 +61,43 @@ static int mtdsplit_parse_minor(struct mtd_info *master,
hdr_len = sizeof(hdr);
err = mtd_read(master, 0, hdr_len, &retlen, (void *) &hdr);
- if (err)
+ if (err) {
+ pr_err("MiNOR mtd_read error: %d\n", err);
return err;
+ }
- if (retlen != hdr_len)
+ if (retlen != hdr_len) {
+ pr_err("MiNOR mtd_read too short\n");
return -EIO;
+ }
/* match header */
- if (hdr.yaffs_type != YAFFS_OBJECT_TYPE_FILE)
- return -EINVAL;
-
- if (hdr.yaffs_obj_id != YAFFS_OBJECTID_ROOT)
- return -EINVAL;
-
- if (hdr.yaffs_sum_unused != YAFFS_SUM_UNUSED)
- return -EINVAL;
-
- if (memcmp(hdr.yaffs_name, YAFFS_NAME, sizeof(YAFFS_NAME)))
- return -EINVAL;
+ if (hdr.yaffs_type != YAFFS_OBJECT_TYPE_FILE) {
+ pr_info("MiNOR YAFFS first type not matched\n");
+ return 0;
+ }
+
+ if (hdr.yaffs_obj_id != YAFFS_OBJECTID_ROOT) {
+ pr_info("MiNOR YAFFS first objectid not matched\n");
+ return 0;
+ }
+
+ if (hdr.yaffs_sum_unused != YAFFS_SUM_UNUSED) {
+ pr_info("MiNOR YAFFS first sum not matched\n");
+ return 0;
+ }
+
+ if (memcmp(hdr.yaffs_name, YAFFS_NAME, sizeof(YAFFS_NAME))) {
+ pr_info("MiNOR YAFFS first name not matched\n");
+ return 0;
+ }
err = mtd_find_rootfs_from(master, master->erasesize, master->size,
&rootfs_offset, NULL);
- if (err)
- return err;
+ if (err) {
+ pr_info("MiNOR mtd_find_rootfs_from error: %d\n", err);
+ return 0;
+ }
parts = kzalloc(MINOR_NR_PARTS * sizeof(*parts), GFP_KERNEL);
if (!parts)