linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kho: Fix NULL pointer dereference in kho_update_memory_map()
@ 2026-03-05 13:12 Zhan Xusheng
  0 siblings, 0 replies; only message in thread
From: Zhan Xusheng @ 2026-03-05 13:12 UTC (permalink / raw)
  To: Alexander Graf; +Cc: linux-mm, linux-kernel, Zhan Xusheng

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 <zhanxusheng@xiaomi.com>
---
 kernel/liveupdate/kexec_handover.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_handover.c
index cc68a3692905..f6ad87930003 100644
--- a/kernel/liveupdate/kexec_handover.c
+++ b/kernel/liveupdate/kexec_handover.c
@@ -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);
-- 
2.43.0



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-03-05 13:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-05 13:12 [PATCH] kho: Fix NULL pointer dereference in kho_update_memory_map() Zhan Xusheng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox