kho: Fix NULL pointer dereference in kho_update_memory_map()
Subsystems (3)
PATCH 1/1 kho: Fix NULL pointer dereference in kho_update_memory_map()
The function kho_update_memory_map currently does not check if the pointer returned by fdt_getprop_w is NULL. If the pointer is NULL, subsequent operations such as dereferencing the pointer or using it in unaligned access functions could cause undefined behavior or crashes. Prevent that.
Signed-off-by Zhan Xusheng <[email protected]>
--- kernel/liveupdate/kexec_handover.c | 2 ++ 1 file changed, 2 insertions(+)
kernel/liveupdate/kexec_handover.c +2 -0
@@ -397,6 +397,8 @@ static void kho_update_memory_map(struct khoser_mem_chunk *first_chunk)u64 phys; ptr =fdt_getprop_w (kho_out.fdt,0 ,KHO_FDT_MEMORY_MAP_PROP_NAME ,NULL ); +if (!ptr) +return ;/* Check and discard previous memory map */ phys =get_unaligned ((u64 *)ptr);
Signature · 1 line
2.43.0