Skip to content

Commit 9b32b06

Browse files
committed
erofs: ensure m_llen is reset to 0 if metadata is invalid
Sometimes, the on-disk metadata might be invalid due to user interrupts, storage failures, or other unknown causes. In that case, z_erofs_map_blocks_iter() may still return a valid m_llen while other fields remain invalid (e.g., m_plen can be 0). Due to the return value of z_erofs_scan_folio() in some path will be ignored on purpose, the following z_erofs_scan_folio() could then use the invalid value by accident. Let's reset m_llen to 0 to prevent this. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Gao Xiang <[email protected]>
1 parent cc69a68 commit 9b32b06

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

fs/erofs/zmap.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,8 @@ int z_erofs_map_blocks_iter(struct inode *inode, struct erofs_map_blocks *map,
711711

712712
err = z_erofs_do_map_blocks(inode, map, flags);
713713
out:
714+
if (err)
715+
map->m_llen = 0;
714716
trace_z_erofs_map_blocks_iter_exit(inode, map, flags, err);
715717
return err;
716718
}

0 commit comments

Comments
 (0)