mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2025-08-24 15:31:22 +01:00
lib: fix fdt_parse_plicsw_node()
cpu_offset and cpu_intc_offset must be int to detect failed invocations of fdt_node_offset_by_phandle() or fdt_parent_offset(). After determining cpu_offset we have to check this value and not cpu_intc_offset. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Xiang W <wxjstz@126.com> Reviewed-by: Yu Chien Peter Lin <peterlin@andestech.com> Reviewed-by: Bin Meng <bmeng@tinylab.org>
This commit is contained in:

committed by
Anup Patel

parent
e9bc7f1757
commit
5daa0ef087
@@ -861,7 +861,7 @@ int fdt_parse_plicsw_node(void *fdt, int nodeoffset, unsigned long *plicsw_base,
|
||||
{
|
||||
const fdt32_t *val;
|
||||
int rc, i, count;
|
||||
uint64_t reg_addr, reg_size, cpu_offset, cpu_intc_offset;
|
||||
uint64_t reg_addr, reg_size;
|
||||
u32 phandle, hwirq, hartid, hcount;
|
||||
|
||||
if (nodeoffset < 0 || !fdt || !plicsw_base ||
|
||||
@@ -882,6 +882,8 @@ int fdt_parse_plicsw_node(void *fdt, int nodeoffset, unsigned long *plicsw_base,
|
||||
|
||||
hcount = 0;
|
||||
for (i = 0; i < (count / 2); i++) {
|
||||
int cpu_offset, cpu_intc_offset;
|
||||
|
||||
phandle = fdt32_to_cpu(val[2 * i]);
|
||||
hwirq = fdt32_to_cpu(val[2 * i + 1]);
|
||||
|
||||
@@ -890,7 +892,7 @@ int fdt_parse_plicsw_node(void *fdt, int nodeoffset, unsigned long *plicsw_base,
|
||||
continue;
|
||||
|
||||
cpu_offset = fdt_parent_offset(fdt, cpu_intc_offset);
|
||||
if (cpu_intc_offset < 0)
|
||||
if (cpu_offset < 0)
|
||||
continue;
|
||||
|
||||
rc = fdt_parse_hart_id(fdt, cpu_offset, &hartid);
|
||||
|
Reference in New Issue
Block a user