add patch fix-compile-error-when-using-BUFFER_TRACE
[ext4-patch-queue.git] / fix-some-pointer-dereferences
blob84dffd86f575b5e8fe7149c6a0e4ba73f1f20e35
1 ext4: fix some error pointer dereferences
3 From: Dan Carpenter <dan.carpenter@oracle.com>
5 We can't pass error pointers to brelse().
7 Fixes: fb265c9cb49e ("ext4: add ext4_sb_bread() to disambiguate ENOMEM cases")
8 Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
9 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 Reviewed-by: Jan Kara <jack@suse.cz>
11 ---
12  fs/ext4/xattr.c | 3 +++
13  1 file changed, 3 insertions(+)
15 diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
16 index 7fddd519adae..6ddbbe21fdd8 100644
17 --- a/fs/ext4/xattr.c
18 +++ b/fs/ext4/xattr.c
19 @@ -829,6 +829,7 @@ int ext4_get_inode_usage(struct inode *inode, qsize_t *usage)
20                 bh = ext4_sb_bread(inode->i_sb, EXT4_I(inode)->i_file_acl, REQ_PRIO);
21                 if (IS_ERR(bh)) {
22                         ret = PTR_ERR(bh);
23 +                       bh = NULL;
24                         goto out;
25                 }
27 @@ -2903,6 +2904,7 @@ int ext4_xattr_delete_inode(handle_t *handle, struct inode *inode,
28                         if (error == -EIO)
29                                 EXT4_ERROR_INODE(inode, "block %llu read error",
30                                                  EXT4_I(inode)->i_file_acl);
31 +                       bh = NULL;
32                         goto cleanup;
33                 }
34                 error = ext4_xattr_check_block(inode, bh);
35 @@ -3059,6 +3061,7 @@ ext4_xattr_block_cache_find(struct inode *inode,
36                 if (IS_ERR(bh)) {
37                         if (PTR_ERR(bh) == -ENOMEM)
38                                 return NULL;
39 +                       bh = NULL;
40                         EXT4_ERROR_INODE(inode, "block %lu read error",
41                                          (unsigned long)ce->e_value);
42                 } else if (ext4_xattr_cmp(header, BHDR(bh)) == 0) {
43 -- 
44 2.17.1