From 3a506b824d1d54ca11a7146f369ac549f2cfa0f0 Mon Sep 17 00:00:00 2001 From: zhangzhengming Date: Mon, 27 Oct 2025 21:20:01 +0800 Subject: [PATCH] LoongArch: Fix the improper handling of the set_virtual_map's return value The condition (status < 0) in efi_runtime_init will never be true because efi_status_t is an unsigned type. This results in unexpected behavior when set_virtual_map fails. Signed-off-by: zhangzhengming --- arch/loongarch/kernel/efi.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/arch/loongarch/kernel/efi.c b/arch/loongarch/kernel/efi.c index 76845a225e97..913da5601869 100644 --- a/arch/loongarch/kernel/efi.c +++ b/arch/loongarch/kernel/efi.c @@ -233,7 +233,7 @@ static int __init set_virtual_map(void) void __init efi_runtime_init(void) { - efi_status_t status; + int ret; if (!efi_enabled(EFI_BOOT) || !efi_systab->runtime) return; @@ -243,9 +243,11 @@ void __init efi_runtime_init(void) return; } - status = set_virtual_map(); - if (status < 0) + ret = set_virtual_map(); + if (ret < 0) { + pr_info("set virtual address map failed, EFI runtime services will not be available.\n"); return; + } efi.runtime = READ_ONCE(efi_systab->runtime); efi.runtime_version = (unsigned int)efi.runtime->hdr.revision; -- Gitee