Skip to content

Commit

Permalink
btrfs: check correct variable after allocation in btrfs_backref_iter_…
Browse files Browse the repository at this point in the history
…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: a37f232 ("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>
  • Loading branch information
Boleyn Su authored and David Sterba committed Aug 10, 2020
1 parent faa0088 commit c15c2ec
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/btrfs/backref.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit c15c2ec

Please sign in to comment.