If the list is not initialized, don't try to free it.
Otherwise it will cause segmentfault.
Signed-off-by: Gui Hecheng <guihc.fnst@xxxxxxxxxxxxxx>
---
mkfs.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/mkfs.c b/mkfs.c
index d7049c9..df22c3a 100644
--- a/mkfs.c
+++ b/mkfs.c
@@ -965,7 +965,7 @@ static int make_image(char *source_dir, struct btrfs_root *root, int out_fd)
ret = lstat(source_dir, &root_st);
if (ret) {
fprintf(stderr, "unable to lstat the %s\n", source_dir);
- goto fail;
+ goto out;
}
INIT_LIST_HEAD(&dir_head.list);
@@ -987,6 +987,7 @@ fail:
list_del(&dir_entry->list);
free(dir_entry);
}
+out:
fprintf(stderr, "Making image is aborted.\n");
return -1;
}
--
1.8.1.4
--
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