linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Zhan Xusheng <zhanxusheng1024@gmail.com>
To: Alexander Graf <graf@amazon.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Zhan Xusheng <zhanxusheng@xiaomi.com>
Subject: [PATCH] kho: Fix NULL pointer dereference in kho_update_memory_map()
Date: Thu,  5 Mar 2026 21:12:07 +0800	[thread overview]
Message-ID: <20260305131207.5584-1-zhanxusheng@xiaomi.com> (raw)

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



                 reply	other threads:[~2026-03-05 13:12 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260305131207.5584-1-zhanxusheng@xiaomi.com \
    --to=zhanxusheng1024@gmail.com \
    --cc=graf@amazon.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=zhanxusheng@xiaomi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox