[PATCH v3 09/10] ext4: Make sure there is at least one sector per block

Simon Glass sjg at chromium.org
Sat May 10 15:06:15 CEST 2025


The implementation assumes that a sector can fit in a block, so add a
check for this.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

(no changes since v1)

 fs/ext4/ext4_write.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/ext4/ext4_write.c b/fs/ext4/ext4_write.c
index 9b1e26e86a7..a48d1fd26be 100644
--- a/fs/ext4/ext4_write.c
+++ b/fs/ext4/ext4_write.c
@@ -615,6 +615,8 @@ int ext4fs_init(void)
 	/* populate fs */
 	fs->blksz = EXT2_BLOCK_SIZE(ext4fs_root);
 	fs->sect_perblk = fs->blksz >> fs->dev_desc->log2blksz;
+	if (!fs->sect_perblk)
+		goto fail;
 
 	/* get the superblock */
 	fs->sb = zalloc(SUPERBLOCK_SIZE);
-- 
2.43.0



More information about the U-Boot mailing list