diff mbox

[3/3] btrfs-progs: plug memory leaks in btrfs_scan_one_dir() reported by cppcheck.

Message ID 1352954872-13770-4-git-send-email-okimoto@clear-code.com (mailing list archive)
State New, archived
Headers show

Commit Message

Kenji Okimoto Nov. 15, 2012, 4:47 a.m. UTC
[utils.c:983]: (error) Memory leak: fullpath

Signed-off-by: Kenji Okimoto <okimoto@clear-code.com>
---
 utils.c |    3 +++
 1 file changed, 3 insertions(+)
diff mbox

Patch

diff --git a/utils.c b/utils.c
index 205e667..3efb3af 100644
--- a/utils.c
+++ b/utils.c
@@ -980,6 +980,7 @@  again:
 	dirp = opendir(dirname);
 	if (!dirp) {
 		fprintf(stderr, "Unable to open %s for scanning\n", dirname);
+		free(fullpath);
 		return -ENOENT;
 	}
 	while(1) {
@@ -1030,6 +1031,7 @@  again:
 		free(pending);
 		pending = list_entry(pending_list.next, struct pending_dir,
 				     list);
+		free(fullpath);
 		list_del(&pending->list);
 		closedir(dirp);
 		dirp = NULL;
@@ -1038,6 +1040,7 @@  again:
 	ret = 0;
 fail:
 	free(pending);
+	free(fullpath);
 	if (dirp)
 		closedir(dirp);
 	return ret;