From 8591711afb6fc2ff120b63f72596154478423182 Mon Sep 17 00:00:00 2001 From: David Sterba Date: Sat, 16 Mar 2024 19:21:43 +0100 Subject: [PATCH] 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 --- check/main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/check/main.c b/check/main.c index a7439d61..c29ce7c8 100644 --- a/check/main.c +++ b/check/main.c @@ -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; }