btrfs-progs: skip erroneous free before initialization

If the list is not initialized, don't try to free it.
Otherwise it will cause segmentfault.

Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
This commit is contained in:
Gui Hecheng 2014-03-13 13:01:31 +08:00 committed by Chris Mason
parent c543daa68b
commit 64200e4453

3
mkfs.c
View File

@ -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;
}