Thank you for your contribution! Sashiko AI review found 1 potential issue(s) 
to consider:
- [High] Missing error handling leads to boot panic
--

commit 84425fcb93791aa9b9c2db978b57ed659f2c9ec2
Author: Pratyush Yadav (Google) <[email protected]>

kho: store incoming radix tree in kho_in

This commit stores the incoming radix tree in the kho_in struct to allow
other functions to use it. It also refactors the code to use
kho_get_mem_map_phys() for retrieving the radix tree root from the FDT.

> diff --git a/kernel/liveupdate/kexec_handover.c 
> b/kernel/liveupdate/kexec_handover.c
> --- a/kernel/liveupdate/kexec_handover.c
> +++ b/kernel/liveupdate/kexec_handover.c

[ ... ]

> @@ -1395,24 +1396,10 @@ EXPORT_SYMBOL_GPL(kho_retrieve_subtree);
>  
>  static int __init kho_mem_retrieve(const void *fdt)
>  {
> -     struct kho_radix_tree tree;
> -     const phys_addr_t *mem;
> -     int len;
> -
> -     /* Retrieve the KHO radix tree from passed-in FDT. */
> -     mem = fdt_getprop(fdt, 0, KHO_FDT_MEMORY_MAP_PROP_NAME, &len);
> -
> -     if (!mem || len != sizeof(*mem)) {
> -             pr_err("failed to get preserved KHO memory tree\n");
> -             return -ENOENT;
> -     }
> -
> -     if (!*mem)
> -             return -EINVAL;
> -
> -     tree.root = phys_to_virt(*mem);
> -     mutex_init(&tree.lock);
> -     return kho_radix_walk_tree(&tree, kho_preserved_memory_reserve);
> +     kho_in.radix_tree.root = phys_to_virt(kho_get_mem_map_phys(fdt));

[Severity: High]
Can this lead to a boot panic if kho_get_mem_map_phys() fails?

If kho_get_mem_map_phys() returns 0 on failure, phys_to_virt(0) will likely 
generate a non-NULL pointer. This bypasses the safety validation later when 
walking the tree:

kernel/liveupdate/kexec_handover.c:kho_radix_walk_tree()
    if (WARN_ON_ONCE(!tree->root))
        return -EINVAL;

Walking the tree with this invalid address would then trigger a panic during 
early boot.

I note this issue appears to be fixed later in the series by commit 
80928d5942267 (kho: return virtual address of mem_map), but wanted to point 
out the temporary breakage here.

> +     mutex_init(&kho_in.radix_tree.lock);
> +     return kho_radix_walk_tree(&kho_in.radix_tree,
> +                                kho_preserved_memory_reserve);
>  }

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=2

Reply via email to