[openwrt/openwrt] kernel: mtdsplit_h3c_vfs: return 0 for non-fatal errors
LEDE Commits
lede-commits at lists.infradead.org
Sun Jul 27 09:25:56 PDT 2025
hauke pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/6fa1775348d5415129db12c05a993c8571c867c2
commit 6fa1775348d5415129db12c05a993c8571c867c2
Author: Jan Hoffmann <jan at 3e8.eu>
AuthorDate: Sun Jul 20 19:07:29 2025 +0200
kernel: mtdsplit_h3c_vfs: return 0 for non-fatal errors
Since Linux 6.7, introduced with commit 5c2f7727d437 ("mtd: mtdpart:
check for subpartitions parsing result"), errors during subpartition
parsing cause all MTD partitions to be torn down.
Since the current mtdsplit driver for devices using H3C VFS returns
-EINVAL if it does not find a file system containing an OpenWrt image,
this makes initial installation of OpenWrt impossible.
Work around this by returning 0 when the file system contains unexpected
data. Also print a message in this case to show what is going on.
Signed-off-by: Jan Hoffmann <jan at 3e8.eu>
Link: https://github.com/openwrt/openwrt/pull/19475
Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
---
.../files/drivers/mtd/mtdsplit/mtdsplit_h3c_vfs.c | 29 ++++++++++------------
1 file changed, 13 insertions(+), 16 deletions(-)
diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_h3c_vfs.c b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_h3c_vfs.c
index f264233dbd..25993e762b 100644
--- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_h3c_vfs.c
+++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_h3c_vfs.c
@@ -98,8 +98,11 @@ static int mtdsplit_h3c_vfs_parse(struct mtd_info *mtd,
if (retlen != sizeof(format_flag))
return -EIO;
- if (format_flag != FORMAT_FLAG)
- return -EINVAL;
+ if (format_flag != FORMAT_FLAG) {
+ pr_info("mtdsplit_h3c_vfs: unexpected format flag %08x\n",
+ format_flag);
+ return 0;
+ }
/* Check file entry */
err = mtd_read(mtd, FILE_ENTRY_OFFSET, sizeof(file_entry), &retlen,
@@ -110,20 +113,14 @@ static int mtdsplit_h3c_vfs_parse(struct mtd_info *mtd,
if (retlen != sizeof(file_entry))
return -EIO;
- if (file_entry.flags != FILE_ENTRY_FLAGS)
- return -EINVAL;
-
- if (file_entry.parent_block != FILE_ENTRY_PARENT_BLOCK)
- return -EINVAL;
-
- if (file_entry.parent_index != FILE_ENTRY_PARENT_INDEX)
- return -EINVAL;
-
- if (file_entry.data_block != FILE_ENTRY_DATA_BLOCK)
- return -EINVAL;
-
- if (strncmp(file_entry.name, FILE_ENTRY_NAME, sizeof(file_entry.name)) != 0)
- return -EINVAL;
+ if (file_entry.flags != FILE_ENTRY_FLAGS ||
+ file_entry.parent_block != FILE_ENTRY_PARENT_BLOCK ||
+ file_entry.parent_index != FILE_ENTRY_PARENT_INDEX ||
+ file_entry.data_block != FILE_ENTRY_DATA_BLOCK ||
+ strncmp(file_entry.name, FILE_ENTRY_NAME, sizeof(file_entry.name)) != 0) {
+ pr_info("mtdsplit_h3c_vfs: unexpected file entry - OpenWrt probably not installed\n");
+ return 0;
+ }
/* Find rootfs offset */
kernel_size = block_offset(file_entry.data_block +
More information about the lede-commits
mailing list