Skip to content

Commit ac398f5

Browse files
Guangshuo Lichenhuacai
authored andcommitted
LoongArch: vDSO: Check kcalloc() result in init_vdso()
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: 2ed119a ("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>
1 parent 677d4a5 commit ac398f5

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

arch/loongarch/kernel/vdso.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ static int __init init_vdso(void)
5454
vdso_info.code_mapping.pages =
5555
kcalloc(vdso_info.size / PAGE_SIZE, sizeof(struct page *), GFP_KERNEL);
5656

57+
if (!vdso_info.code_mapping.pages)
58+
return -ENOMEM;
59+
5760
pfn = __phys_to_pfn(__pa_symbol(vdso_info.vdso));
5861
for (i = 0; i < vdso_info.size / PAGE_SIZE; i++)
5962
vdso_info.code_mapping.pages[i] = pfn_to_page(pfn + i);

0 commit comments

Comments
 (0)