From: Baokun Li Date: Thu, 22 Aug 2024 02:35:30 +0000 (+0800) Subject: ext4: propagate errors from ext4_find_extent() in ext4_insert_range() X-Git-Tag: v6.12-rc1~117^2~24 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=369c944ed1d7c3fb7b35f24e4735761153afe7b3;p=thirdparty%2Fkernel%2Fstable.git ext4: propagate errors from ext4_find_extent() in ext4_insert_range() Even though ext4_find_extent() returns an error, ext4_insert_range() still returns 0. This may confuse the user as to why fallocate returns success, but the contents of the file are not as expected. So propagate the error returned by ext4_find_extent() to avoid inconsistencies. Fixes: 331573febb6a ("ext4: Add support FALLOC_FL_INSERT_RANGE for fallocate") Cc: stable@kernel.org Signed-off-by: Baokun Li Reviewed-by: Jan Kara Reviewed-by: Ojaswin Mujoo Tested-by: Ojaswin Mujoo Link: https://patch.msgid.link/20240822023545.1994557-11-libaokun@huaweicloud.com Signed-off-by: Theodore Ts'o --- diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index 94068f1a0d85a..e2f89ca3e1384 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -5541,6 +5541,7 @@ static int ext4_insert_range(struct file *file, loff_t offset, loff_t len) path = ext4_find_extent(inode, offset_lblk, NULL, 0); if (IS_ERR(path)) { up_write(&EXT4_I(inode)->i_data_sem); + ret = PTR_ERR(path); goto out_stop; }