diff options
author | Tom Rix <trix@redhat.com> | 2020-07-07 16:29:08 +0300 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2020-07-27 13:55:43 +0300 |
commit | d60ba8de1164e1b42e296ff270c622a070ef8fe7 (patch) | |
tree | 7070eb8e92ebde69efcc9a3b2df2bd85c554ac88 /fs/btrfs | |
parent | d85327b1d8b74ec168ed34c798a424de82fdc001 (diff) | |
download | linux-d60ba8de1164e1b42e296ff270c622a070ef8fe7.tar.xz |
btrfs: ref-verify: fix memory leak in add_block_entry
clang static analysis flags this error
fs/btrfs/ref-verify.c:290:3: warning: Potential leak of memory pointed to by 're' [unix.Malloc]
kfree(be);
^~~~~
The problem is in this block of code:
if (root_objectid) {
struct root_entry *exist_re;
exist_re = insert_root_entry(&exist->roots, re);
if (exist_re)
kfree(re);
}
There is no 'else' block freeing when root_objectid is 0. Add the
missing kfree to the else branch.
Fixes: fd708b81d972 ("Btrfs: add a extent ref verify tool")
CC: stable@vger.kernel.org # 4.19+
Signed-off-by: Tom Rix <trix@redhat.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r-- | fs/btrfs/ref-verify.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/btrfs/ref-verify.c b/fs/btrfs/ref-verify.c index af92525dbb16..7f03dbe5b609 100644 --- a/fs/btrfs/ref-verify.c +++ b/fs/btrfs/ref-verify.c @@ -286,6 +286,8 @@ static struct block_entry *add_block_entry(struct btrfs_fs_info *fs_info, exist_re = insert_root_entry(&exist->roots, re); if (exist_re) kfree(re); + } else { + kfree(re); } kfree(be); return exist; |