diff options
author | Gui Hecheng <guihc.fnst@cn.fujitsu.com> | 2013-09-05 10:38:57 +0800 |
---|---|---|
committer | Chris Mason <chris.mason@fusionio.com> | 2013-10-16 08:20:42 -0400 |
commit | aea22fa1b55e3e8830c8d46f2d7e4731f1b58fcf (patch) | |
tree | 6b0c4c712e5cba0bcf1edd8dcde25aa957f3df54 | |
parent | 0785476db045ba599ae4dd5517a1b11bc36ac811 (diff) |
btrfs-progs: free the local list pending_list in btrfs_scan_one_dir
Originally the local pending_list is not guaranteed to be freed upon
fails, it should be emptyed and the elements should be freed.
Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
-rw-r--r-- | utils.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -1066,8 +1066,8 @@ again: dirp = opendir(dirname); if (!dirp) { fprintf(stderr, "Unable to open %s for scanning\n", dirname); - free(fullpath); - return -ENOENT; + ret = -ENOENT; + goto fail; } while(1) { dirent = readdir(dirp); @@ -1133,6 +1133,12 @@ again: fail: free(pending); free(fullpath); + while (!list_empty(&pending_list)) { + pending = list_entry(pending_list.next, struct pending_dir, + list); + list_del(&pending->list); + free(pending); + } if (dirp) closedir(dirp); return ret; |