Linux Btrfs filesystem development
 help / color / mirror / Atom feed
* [PATCH] btrfs-progs: verify_space_cache: Fix memory leak.
@ 2013-09-22 12:31 chandan
  0 siblings, 0 replies; only message in thread
From: chandan @ 2013-09-22 12:31 UTC (permalink / raw)
  To: linux-btrfs; +Cc: sekharan

Free btrfs_path structure before returning due to failure of calls to
btrfs_search_slot() or btrfs_next_leaf() functions.

Signed-off-by: chandan <chandan@linux.vnet.ibm.com>
---
 cmds-check.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/cmds-check.c b/cmds-check.c
index e08b79d..c947156 100644
--- a/cmds-check.c
+++ b/cmds-check.c
@@ -3227,14 +3227,19 @@ static int verify_space_cache(struct btrfs_root *root,
 	key.type = BTRFS_EXTENT_ITEM_KEY;
 
 	ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
-	if (ret < 0)
+	if (ret < 0) {
+		btrfs_free_path(path);
 		return ret;
+	}
+
 	ret = 0;
 	while (1) {
 		if (path->slots[0] >= btrfs_header_nritems(path->nodes[0])) {
 			ret = btrfs_next_leaf(root, path);
-			if (ret < 0)
+			if (ret < 0) {
+				btrfs_free_path(path);
 				return ret;
+			}
 			if (ret > 0) {
 				ret = 0;
 				break;
-- 
1.8.3.1



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2013-09-22 12:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-22 12:31 [PATCH] btrfs-progs: verify_space_cache: Fix memory leak chandan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox