Skip to contentSkip to conversation

erofs-utils: lib: fix inappropriate initialization in cache.c

PATCH In review Hongzhen Luo 2 participants 2 messages Mar 3, 2025 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 erofs-utils: lib: fix inappropriate initialization in cache.c

This patch fixes the inappropriate initialization of dsunit and bktmap in cache.c.

Fixes 8bb6de4e7c41 ("erofs-utils: mkfs: support data alignment")
Fixes ca0f040f98b6 ("erofs-utils: lib: use bitmaps to accelerate bucket selection")
---
 lib/cache.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
lib/cache.c +3 -1
index ca1061bc7f29..eddf21f49893 100644
@@ -44,13 +44,15 @@ struct erofs_bufmgr *erofs_buffer_init(struct erofs_sb_info *sbi,
 		for (j = 0; j < ARRAY_SIZE(bmgr->watermeter[0]); j++) {
 			for (k = 0; k < blksiz; k++)
 				init_list_head(&bmgr->watermeter[i][j][k]);
-			memset(bmgr->bktmap[i][j], 0, blksiz / BITS_PER_LONG);
+			memset(bmgr->bktmap[i][j], 0,
+			       (blksiz / BITS_PER_LONG) * sizeof(unsigned long));
 		}
 	}
 	init_list_head(&bmgr->blkh.list);
 	bmgr->blkh.blkaddr = NULL_ADDR;
 	bmgr->tail_blkaddr = startblk;
 	bmgr->last_mapped_block = &bmgr->blkh;
+	bmgr->dsunit = 0;
 	return bmgr;
 }
 
Signature · 1 line
2.43.5
#1 lore raw
Quoted 6 lines · Hongzhen Luo

This patch fixes the inappropriate initialization of dsunit and bktmap in cache.c.

Fixes 8bb6de4e7c41 ("erofs-utils: mkfs: support data alignment")
Fixes ca0f040f98b6 ("erofs-utils: lib: use bitmaps to accelerate bucket selection")

Nice catch! Applied.

Thanks,
Gao Xiang