summaryrefslogtreecommitdiff
path: root/fs/ext4/xattr.c
diff options
context:
space:
mode:
authorVasily Averin <vvs@virtuozzo.com>2018-11-07 11:14:35 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-11-21 09:19:22 +0100
commitb0f2b1fea812073888005c489f99766ab350c09b (patch)
treee7ad0e6425c3eaff953ed0217237016a803741c2 /fs/ext4/xattr.c
parent29ee4d62f6dbd906f032b6ca8743a5b8ff2c1e76 (diff)
ext4: fix buffer leak in ext4_expand_extra_isize_ea() on error path
commit 53692ec074d00589c2cf1d6d17ca76ad0adce6ec upstream. Fixes: de05ca852679 ("ext4: move call to ext4_error() into ...") Signed-off-by: Vasily Averin <vvs@virtuozzo.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu> Cc: stable@kernel.org # 4.17 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/ext4/xattr.c')
-rw-r--r--fs/ext4/xattr.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
index fe97ce454a44..4380c8630539 100644
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -2708,7 +2708,6 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize,
struct ext4_inode *raw_inode, handle_t *handle)
{
struct ext4_xattr_ibody_header *header;
- struct buffer_head *bh;
struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
static unsigned int mnt_count;
size_t min_offs;
@@ -2749,13 +2748,17 @@ retry:
* EA block can hold new_extra_isize bytes.
*/
if (EXT4_I(inode)->i_file_acl) {
+ struct buffer_head *bh;
+
bh = sb_bread(inode->i_sb, EXT4_I(inode)->i_file_acl);
error = -EIO;
if (!bh)
goto cleanup;
error = ext4_xattr_check_block(inode, bh);
- if (error)
+ if (error) {
+ brelse(bh);
goto cleanup;
+ }
base = BHDR(bh);
end = bh->b_data + bh->b_size;
min_offs = end - base;