Skip to content

Commit ae9e9c6

Browse files
jankaratytso
authored andcommitted
ext4: make ext4_ext_convert_to_initialized() return proper number of blocks
ext4_ext_convert_to_initialized() can return more blocks than are actually allocated from map->m_lblk in case where initial part of the on-disk extent is zeroed out. Luckily this doesn't have serious consequences because the caller currently uses the return value only to unmap metadata buffers. Anyway this is a data corruption/exposure problem waiting to happen so fix it. Coverity-id: 1226848 Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
1 parent 4f879ca commit ae9e9c6

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

fs/ext4/extents.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3603,11 +3603,10 @@ static int ext4_ext_convert_to_initialized(handle_t *handle,
36033603
}
36043604
}
36053605

3606-
allocated = ext4_split_extent(handle, inode, ppath,
3607-
&split_map, split_flag, flags);
3608-
if (allocated < 0)
3609-
err = allocated;
3610-
3606+
err = ext4_split_extent(handle, inode, ppath, &split_map, split_flag,
3607+
flags);
3608+
if (err > 0)
3609+
err = 0;
36113610
out:
36123611
/* If we have gotten a failure, don't zero out status tree */
36133612
if (!err)

0 commit comments

Comments
 (0)