]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
ext4: fix some error pointer dereferences
authorDan Carpenter <dan.carpenter@oracle.com>
Thu, 21 Feb 2019 16:17:34 +0000 (11:17 -0500)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 14 Aug 2019 09:18:49 +0000 (11:18 +0200)
BugLink: https://bugs.launchpad.net/bugs/1838459
commit 7159a986b4202343f6cca3bb8079ecace5816fd6 upstream.

We can't pass error pointers to brelse().

Fixes: fb265c9cb49e ("ext4: add ext4_sb_bread() to disambiguate ENOMEM cases")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
fs/ext4/xattr.c

index 1fe5ed8fa6a8615e681ed35081d0e2b872425edf..ad960e08593d5d56a4791f1df7fa6defed0abc02 100644 (file)
@@ -828,6 +828,7 @@ int ext4_get_inode_usage(struct inode *inode, qsize_t *usage)
                bh = ext4_sb_bread(inode->i_sb, EXT4_I(inode)->i_file_acl, REQ_PRIO);
                if (IS_ERR(bh)) {
                        ret = PTR_ERR(bh);
+                       bh = NULL;
                        goto out;
                }
 
@@ -2906,6 +2907,7 @@ int ext4_xattr_delete_inode(handle_t *handle, struct inode *inode,
                        if (error == -EIO)
                                EXT4_ERROR_INODE(inode, "block %llu read error",
                                                 EXT4_I(inode)->i_file_acl);
+                       bh = NULL;
                        goto cleanup;
                }
                error = ext4_xattr_check_block(inode, bh);
@@ -3062,6 +3064,7 @@ ext4_xattr_block_cache_find(struct inode *inode,
                if (IS_ERR(bh)) {
                        if (PTR_ERR(bh) == -ENOMEM)
                                return NULL;
+                       bh = NULL;
                        EXT4_ERROR_INODE(inode, "block %lu read error",
                                         (unsigned long)ce->e_value);
                } else if (ext4_xattr_cmp(header, BHDR(bh)) == 0) {