btrfs-progs: check: free memory on failure in get_inode_rec()

Free the newly allocated structures when 'mod' is requests and insertion
fails. All exit paths from the function now don't leave anything to
clean up.

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2024-03-16 19:21:43 +01:00
parent 054b314fbe
commit 8591711afb
1 changed files with 4 additions and 1 deletions

View File

@ -776,8 +776,11 @@ static struct inode_record *get_inode_rec(struct cache_tree *inode_cache,
rec->found_link = 1;
ret = insert_cache_extent(inode_cache, &node->cache);
if (ret)
if (ret) {
free(rec);
free(node);
return ERR_PTR(-EEXIST);
}
}
return rec;
}