]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
btrfs: check correct variable after allocation in btrfs_backref_iter_alloc
authorBoleyn Su <boleynsu@google.com>
Thu, 6 Aug 2020 06:31:44 +0000 (15:31 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 21 Aug 2020 11:14:52 +0000 (13:14 +0200)
commit c15c2ec07a26b251040943a1a9f90d3037f041e5 upstream.

The `if (!ret)` check will always be false and it may result in
ret->path being dereferenced while it is a NULL pointer.

Fixes: a37f232b7b65 ("btrfs: backref: introduce the skeleton of btrfs_backref_iter")
CC: stable@vger.kernel.org # 5.8+
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Boleyn Su <boleynsu@google.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/btrfs/backref.c

index ea10f7bc99abf7590b89c1fa888cf8d135aac620..ea1c28ccb44ff95f9cf1a8769af6580d156f4173 100644 (file)
@@ -2303,7 +2303,7 @@ struct btrfs_backref_iter *btrfs_backref_iter_alloc(
                return NULL;
 
        ret->path = btrfs_alloc_path();
-       if (!ret) {
+       if (!ret->path) {
                kfree(ret);
                return NULL;
        }