[PATCH] btrfs-progs: verify_space_cache: Fix memory leak.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxx>
---
 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


--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux