From: Boleyn Su Date: Thu, 6 Aug 2020 06:31:44 +0000 (+0900) Subject: btrfs: check correct variable after allocation in btrfs_backref_iter_alloc X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=c15c2ec07a26b251040943a1a9f90d3037f041e5;p=linux.git 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: a37f232b7b65 ("btrfs: backref: introduce the skeleton of btrfs_backref_iter") CC: stable@vger.kernel.org # 5.8+ Reviewed-by: Nikolay Borisov Reviewed-by: Qu Wenruo Signed-off-by: Boleyn Su Reviewed-by: David Sterba Signed-off-by: David Sterba --- diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c index ea10f7bc99abf..ea1c28ccb44ff 100644 --- a/fs/btrfs/backref.c +++ b/fs/btrfs/backref.c @@ -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; }