xen/arm: bootfdt: Make process_chosen_node() return int

At the boot time, it is saner to stop booting early if an error occurs
when parsing the device tree chosen node, rather than seeing random
behavior afterwards. Therefore, this commit changes the return type of
the process_chosen_node() from void to int, and return correct errno
based on the error type.

Signed-off-by: Henry Wang <Henry.Wang@arm.com>
Reviewed-by: Michal Orzel <michal.orzel@amd.com>
Acked-by: Julien Grall <jgrall@amazon.com>
This commit is contained in:
Henry Wang authored and Julien Grall committed 2022-09-08 12:23:39 +01:00
1 parent 1fe16b3ed7
commit d0d81052b4
1 file changed
+11 -9
+11 -9
View File
@@ -293,9 +293,9 @@ static void __init process_multiboot_node(const void *fdt, int node,
kind, start, domU);
}
static void __init process_chosen_node(const void *fdt, int node,
const char *name,
u32 address_cells, u32 size_cells)
static int __init process_chosen_node(const void *fdt, int node,
const char *name,
u32 address_cells, u32 size_cells)
{
const struct fdt_property *prop;
paddr_t start, end;
@@ -306,11 +306,11 @@ static void __init process_chosen_node(const void *fdt, int node,
prop = fdt_get_property(fdt, node, "linux,initrd-start", &len);
if ( !prop )
/* No initrd present. */
return;
return 0;
if ( len != sizeof(u32) && len != sizeof(u64) )
{
printk("linux,initrd-start property has invalid length %d\n", len);
return;
return -EINVAL;
}
start = dt_read_number((void *)&prop->data, dt_size_to_cells(len));
@@ -318,12 +318,12 @@ static void __init process_chosen_node(const void *fdt, int node,
if ( !prop )
{
printk("linux,initrd-end not present but -start was\n");
return;
return -EINVAL;
}
if ( len != sizeof(u32) && len != sizeof(u64) )
{
printk("linux,initrd-end property has invalid length %d\n", len);
return;
return -EINVAL;
}
end = dt_read_number((void *)&prop->data, dt_size_to_cells(len));
@@ -331,12 +331,14 @@ static void __init process_chosen_node(const void *fdt, int node,
{
printk("linux,initrd limits invalid: %"PRIpaddr" >= %"PRIpaddr"\n",
start, end);
return;
return -EINVAL;
}
printk("Initrd %"PRIpaddr"-%"PRIpaddr"\n", start, end);
add_boot_module(BOOTMOD_RAMDISK, start, end-start, false);
return 0;
}
static int __init process_domain_node(const void *fdt, int node,
@@ -383,7 +385,7 @@ static int __init early_scan_node(const void *fdt,
device_tree_node_compatible(fdt, node, "multiboot,module" )))
process_multiboot_node(fdt, node, name, address_cells, size_cells);
else if ( depth == 1 && device_tree_node_matches(fdt, node, "chosen") )
process_chosen_node(fdt, node, name, address_cells, size_cells);
rc = process_chosen_node(fdt, node, name, address_cells, size_cells);
else if ( depth == 2 && device_tree_node_compatible(fdt, node, "xen,domain") )
rc = process_domain_node(fdt, node, name, address_cells, size_cells);
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.