summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuangshuo Li <202321181@mail.sdu.edu.cn>2025-09-18 19:44:10 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-09-25 11:13:46 +0200
commit382f5ff5701041c3de190933735a871d4051f5f0 (patch)
tree2e07d30cb5325045c66bc7081dfcaa132ec08923
parent040f278cc1a5f3d656e052d2835c3b00518edd2a (diff)
LoongArch: vDSO: Check kcalloc() result in init_vdso()
commit ac398f570724c41e5e039d54e4075519f6af7408 upstream. Add a NULL-pointer check after the kcalloc() call in init_vdso(). If allocation fails, return -ENOMEM to prevent a possible dereference of vdso_info.code_mapping.pages when it is NULL. Cc: stable@vger.kernel.org Fixes: 2ed119aef60d ("LoongArch: Set correct size for vDSO code mapping") Signed-off-by: Guangshuo Li <202321181@mail.sdu.edu.cn> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--arch/loongarch/kernel/vdso.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/arch/loongarch/kernel/vdso.c b/arch/loongarch/kernel/vdso.c
index 2c0d852ca536..0e8793617a2e 100644
--- a/arch/loongarch/kernel/vdso.c
+++ b/arch/loongarch/kernel/vdso.c
@@ -108,6 +108,9 @@ static int __init init_vdso(void)
vdso_info.code_mapping.pages =
kcalloc(vdso_info.size / PAGE_SIZE, sizeof(struct page *), GFP_KERNEL);
+ if (!vdso_info.code_mapping.pages)
+ return -ENOMEM;
+
pfn = __phys_to_pfn(__pa_symbol(vdso_info.vdso));
for (i = 0; i < vdso_info.size / PAGE_SIZE; i++)
vdso_info.code_mapping.pages[i] = pfn_to_page(pfn + i);