add patch fix-buffer-leak-in-ext4_xattr_move_to_block-on-error-path
[ext4-patch-queue.git] / fix-buffer-leak-in-ext4_xattr_get_block-on-error-path
blobfddf561e19ff9610f3a8e1fc19337ad039ad7553
1 ext4: fix buffer leak in ext4_xattr_get_block() on error path
3 From: Vasily Averin <vvs@virtuozzo.com>
5 Fixes: dec214d00e0d ("ext4: xattr inode deduplication")
6 Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
7 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
8 Cc: stable@kernel.org # 4.13
9 ---
10  fs/ext4/xattr.c | 4 +++-
11  1 file changed, 3 insertions(+), 1 deletion(-)
13 diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
14 index dc1aeab06dba..07c3a115f7ae 100644
15 --- a/fs/ext4/xattr.c
16 +++ b/fs/ext4/xattr.c
17 @@ -2272,8 +2272,10 @@ static struct buffer_head *ext4_xattr_get_block(struct inode *inode)
18         if (!bh)
19                 return ERR_PTR(-EIO);
20         error = ext4_xattr_check_block(inode, bh);
21 -       if (error)
22 +       if (error) {
23 +               brelse(bh);
24                 return ERR_PTR(error);
25 +       }
26         return bh;
27  }
29 -- 
30 2.17.1