Skip to content

Commit fa83c34

Browse files
LiBaokun96tytso
authored andcommitted
ext4: check iomap type only if ext4_iomap_begin() does not fail
When ext4_iomap_overwrite_begin() calls ext4_iomap_begin() map blocks may fail for some reason (e.g. memory allocation failure, bare disk write), and later because "iomap->type ! = IOMAP_MAPPED" triggers WARN_ON(). When ext4 iomap_begin() returns an error, it is normal that the type of iomap->type may not match the expectation. Therefore, we only determine if iomap->type is as expected when ext4_iomap_begin() is executed successfully. Cc: [email protected] Reported-by: [email protected] Link: https://lore.kernel.org/all/[email protected] Signed-off-by: Baokun Li <[email protected]> Reviewed-by: Jan Kara <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent 4f04351 commit fa83c34

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/ext4/inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3377,7 +3377,7 @@ static int ext4_iomap_overwrite_begin(struct inode *inode, loff_t offset,
33773377
*/
33783378
flags &= ~IOMAP_WRITE;
33793379
ret = ext4_iomap_begin(inode, offset, length, flags, iomap, srcmap);
3380-
WARN_ON_ONCE(iomap->type != IOMAP_MAPPED);
3380+
WARN_ON_ONCE(!ret && iomap->type != IOMAP_MAPPED);
33813381
return ret;
33823382
}
33833383

0 commit comments

Comments
 (0)