Skip to content

Commit e7bfb5c

Browse files
jankaratytso
authored andcommitted
ext4: handle add_system_zone() failure in ext4_setup_system_zone()
There's one place that fails to handle error from add_system_zone() call and thus we can fail to protect superblock and group-descriptor blocks properly in case of ENOMEM. Fix it. Reported-by: Lukas Czerner <[email protected]> Reviewed-by: Lukas Czerner <[email protected]> Signed-off-by: Jan Kara <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent 3f67e7c commit e7bfb5c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

fs/ext4/block_validity.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,13 @@ int ext4_setup_system_zone(struct super_block *sb)
235235
for (i=0; i < ngroups; i++) {
236236
cond_resched();
237237
if (ext4_bg_has_super(sb, i) &&
238-
((i < 5) || ((i % flex_size) == 0)))
239-
add_system_zone(system_blks,
238+
((i < 5) || ((i % flex_size) == 0))) {
239+
ret = add_system_zone(system_blks,
240240
ext4_group_first_block_no(sb, i),
241241
ext4_bg_num_gdb(sb, i) + 1, 0);
242+
if (ret)
243+
goto err;
244+
}
242245
gdp = ext4_get_group_desc(sb, i, NULL);
243246
ret = add_system_zone(system_blks,
244247
ext4_block_bitmap(sb, gdp), 1, 0);

0 commit comments

Comments
 (0)