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@xxxxxxxxxxxxxx>
---
utils.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/utils.c b/utils.c
index d022d58..134bf80 100644
--- a/utils.c
+++ b/utils.c
@@ -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;
--
1.8.0.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