[PATCH 2/2] erofs-utils: mkfs: fix EOD read when calculate sb checksum

Gao Xiang hsiangkao at linux.alibaba.com
Tue Mar 28 14:54:56 AEDT 2023


Since images could be very small for smaller block sizes.

Fixes: a4fb8ea13ac7 ("erofs-utils: support arbitrary block sizes")
Signed-off-by: Gao Xiang <hsiangkao at linux.alibaba.com>
---
 mkfs/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mkfs/main.c b/mkfs/main.c
index 27e3f03..65d3df6 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -614,7 +614,7 @@ static int erofs_mkfs_superblock_csum_set(void)
 	unsigned int len;
 	struct erofs_super_block *sb;
 
-	ret = blk_read(0, buf, 0, erofs_blknr(sizeof(buf)));
+	ret = blk_read(0, buf, 0, erofs_blknr(EROFS_SUPER_END) + 1);
 	if (ret) {
 		erofs_err("failed to read superblock to set checksum: %s",
 			  erofs_strerror(ret));
-- 
2.24.4



More information about the Linux-erofs mailing list