[openwrt/openwrt] kernel: mtdsplit_minor: return 0 if not fatal
LEDE Commits
lede-commits at lists.infradead.org
Wed Oct 30 03:15:38 PDT 2024
robimarko pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/ade045084bd3f86969eaf0b35234aaa01e430fe1
commit ade045084bd3f86969eaf0b35234aaa01e430fe1
Author: John Thomson <git at johnthomson.fastmail.com.au>
AuthorDate: Wed Oct 16 07:13:25 2024 +1000
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 at johnthomson.fastmail.com.au>
Acked-by: Thibaut VARENE <hacks at slashdirt.org>
Link: https://github.com/openwrt/openwrt/pull/16780
Signed-off-by: Robert Marko <robimarko at gmail.com>
---
.../files/drivers/mtd/mtdsplit/mtdsplit_minor.c | 44 ++++++++++++++--------
1 file 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)
More information about the lede-commits
mailing list