Skip to content

Commit

Permalink
trivial: check dtb_base_name before open
Browse files Browse the repository at this point in the history
Trying to open an empty file will trigger this warning:
sys_open_impl@sys_io.c:192 Failed to open file

This commit checks if the dtb_base_name is an empty string before
attempting to open it.

Signed-off-by: Chris Guikema <[email protected]>
  • Loading branch information
chrisguikema authored and kent-mcleod committed Oct 27, 2022
1 parent 8ac3ee8 commit e5f8ec6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion components/VM_Arm/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,13 @@ static int load_linux(vm_t *vm, const char *kernel_name, const char *dtb_name, c
paths = camkes_dtb_get_node_paths(&num_paths);
}

int dtb_fd = open(linux_image_config.dtb_base_name, 0);
int dtb_fd = -1;

/* No point checking the file server if the string is empty! */
if ((NULL != linux_image_config.dtb_base_name) &&
(linux_image_config.dtb_base_name[0] != '\0')) {
dtb_fd = open(linux_image_config.dtb_base_name, 0);
}

/* If dtb_base_name is in the file server, grab it and use it as a base */
if (dtb_fd >= 0) {
Expand Down

0 comments on commit e5f8ec6

Please sign in to comment.