mirror of
https://github.com/kdave/btrfs-progs
synced 2025-05-01 07:27:59 +00:00
btrfs-progs: handle memory allocation failures in traverse_directory
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
6046bfd5e3
commit
89b40ab5bb
6
mkfs.c
6
mkfs.c
@ -786,6 +786,8 @@ static int traverse_directory(struct btrfs_trans_handle *trans,
|
|||||||
|
|
||||||
/* Add list for source directory */
|
/* Add list for source directory */
|
||||||
dir_entry = malloc(sizeof(struct directory_name_entry));
|
dir_entry = malloc(sizeof(struct directory_name_entry));
|
||||||
|
if (!dir_entry)
|
||||||
|
return -ENOMEM;
|
||||||
dir_entry->dir_name = dir_name;
|
dir_entry->dir_name = dir_name;
|
||||||
dir_entry->path = realpath(dir_name, real_path);
|
dir_entry->path = realpath(dir_name, real_path);
|
||||||
if (!dir_entry->path) {
|
if (!dir_entry->path) {
|
||||||
@ -887,6 +889,10 @@ static int traverse_directory(struct btrfs_trans_handle *trans,
|
|||||||
|
|
||||||
if (S_ISDIR(st.st_mode)) {
|
if (S_ISDIR(st.st_mode)) {
|
||||||
dir_entry = malloc(sizeof(struct directory_name_entry));
|
dir_entry = malloc(sizeof(struct directory_name_entry));
|
||||||
|
if (!dir_entry) {
|
||||||
|
ret = -ENOMEM;
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
dir_entry->dir_name = cur_file->d_name;
|
dir_entry->dir_name = cur_file->d_name;
|
||||||
dir_entry->path = make_path(parent_dir_entry->path,
|
dir_entry->path = make_path(parent_dir_entry->path,
|
||||||
cur_file->d_name);
|
cur_file->d_name);
|
||||||
|
Loading…
Reference in New Issue
Block a user