summaryrefslogtreecommitdiffstats
path: root/fs/udf
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2022-12-15 14:24:03 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-03-11 16:31:49 +0100
commit4d20b48e61b26b8177cd4bf7ddfc3da7cf9aa80c (patch)
treea4a74de748416e3de67a530f248e6d3cdec25977 /fs/udf
parentf0421928d6accb10af618ecf0067a5544991fdfe (diff)
downloadlinux-stable-4d20b48e61b26b8177cd4bf7ddfc3da7cf9aa80c.tar.gz
linux-stable-4d20b48e61b26b8177cd4bf7ddfc3da7cf9aa80c.tar.bz2
linux-stable-4d20b48e61b26b8177cd4bf7ddfc3da7cf9aa80c.zip
udf: Truncate added extents on failed expansion
commit 70bfb3a8d661d4fdc742afc061b88a7f3fc9f500 upstream. When a file expansion failed because we didn't have enough space for indirect extents make sure we truncate extents created so far so that we don't leave extents beyond EOF. CC: stable@vger.kernel.org Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/udf')
-rw-r--r--fs/udf/inode.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index 55a86120e756..07a7f3474cd6 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -521,8 +521,10 @@ static int udf_do_extend_file(struct inode *inode,
}
if (fake) {
- udf_add_aext(inode, last_pos, &last_ext->extLocation,
- last_ext->extLength, 1);
+ err = udf_add_aext(inode, last_pos, &last_ext->extLocation,
+ last_ext->extLength, 1);
+ if (err < 0)
+ goto out_err;
count++;
} else {
struct kernel_lb_addr tmploc;
@@ -556,7 +558,7 @@ static int udf_do_extend_file(struct inode *inode,
err = udf_add_aext(inode, last_pos, &last_ext->extLocation,
last_ext->extLength, 1);
if (err)
- return err;
+ goto out_err;
count++;
}
if (new_block_bytes) {
@@ -565,7 +567,7 @@ static int udf_do_extend_file(struct inode *inode,
err = udf_add_aext(inode, last_pos, &last_ext->extLocation,
last_ext->extLength, 1);
if (err)
- return err;
+ goto out_err;
count++;
}
@@ -579,6 +581,11 @@ out:
return -EIO;
return count;
+out_err:
+ /* Remove extents we've created so far */
+ udf_clear_extent_cache(inode);
+ udf_truncate_extents(inode);
+ return err;
}
/* Extend the final block of the file to final_block_len bytes */