]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
LoongArch: vDSO: Check kcalloc() result in init_vdso()
authorGuangshuo Li <202321181@mail.sdu.edu.cn>
Thu, 18 Sep 2025 11:44:10 +0000 (19:44 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Sep 2025 09:13:46 +0000 (11:13 +0200)
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>
arch/loongarch/kernel/vdso.c

index 2c0d852ca5366b378088a492cf0942d9309dd809..0e8793617a2e9550df7259068380f7a1ff1a3f79 100644 (file)
@@ -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);