diff options
author | Jan Kara <jack@suse.cz> | 2022-12-19 19:54:12 +0100 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2023-01-09 10:39:52 +0100 |
commit | 2b10074d91e053d867148d66ba99552f576b3dd1 (patch) | |
tree | b3871947d3c26e2c4eed2f418e1619ecc7deb6e6 /fs/udf/namei.c | |
parent | 33e9a53cd9f099b138578f8e1a3d60775ff8cbba (diff) |
udf: Handle error when adding extent to symlink
When adding extent describing symlink data fails, make sure to handle
the error properly, propagate it up and free the already allocated
block.
Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/udf/namei.c')
-rw-r--r-- | fs/udf/namei.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/fs/udf/namei.c b/fs/udf/namei.c index a4e8284043c1..261ca813a1b8 100644 --- a/fs/udf/namei.c +++ b/fs/udf/namei.c @@ -613,8 +613,12 @@ static int udf_symlink(struct user_namespace *mnt_userns, struct inode *dir, iinfo->i_location.partitionReferenceNum; bsize = sb->s_blocksize; iinfo->i_lenExtents = bsize; - udf_add_aext(inode, &epos, &eloc, bsize, 0); + err = udf_add_aext(inode, &epos, &eloc, bsize, 0); brelse(epos.bh); + if (err < 0) { + udf_free_blocks(sb, inode, &eloc, 0, 1); + goto out_no_entry; + } block = udf_get_pblock(sb, block, iinfo->i_location.partitionReferenceNum, @@ -622,6 +626,7 @@ static int udf_symlink(struct user_namespace *mnt_userns, struct inode *dir, epos.bh = udf_tgetblk(sb, block); if (unlikely(!epos.bh)) { err = -ENOMEM; + udf_free_blocks(sb, inode, &eloc, 0, 1); goto out_no_entry; } lock_buffer(epos.bh); |