btrfs: check correct variable after allocation in btrfs_backref_iter_alloc

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

Fixes: a37f232b7b ("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>
This commit is contained in:
Boleyn Su 2020-08-06 15:31:44 +09:00 committed by David Sterba
parent faa008899a
commit c15c2ec07a
1 changed files with 1 additions and 1 deletions

View File

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