aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2024-03-16 19:21:43 +0100
committerDavid Sterba <dsterba@suse.com>2024-03-16 23:14:02 +0100
commit8591711afb6fc2ff120b63f72596154478423182 (patch)
tree9a0f9855f029abd8cac06494df924667a381ff24
parent054b314fbe5efc8b115a18bd93dfea52d15ea607 (diff)
downloadbtrfs-progs-8591711afb6fc2ff120b63f72596154478423182.tar.gz
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>
-rw-r--r--check/main.c5
1 files changed, 4 insertions, 1 deletions
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;
}