Re: [PATCH] mm: add missing alloc_percpu() NULL check in hotplug init

From: Mike Rapoport

Date: Fri Jul 17 2026 - 02:52:27 EST


On Fri, Jul 17, 2026 at 01:29:38PM +0800, Hongfu Li wrote:
> From: Hongfu Li <lihongfu@xxxxxxxxxx>
>
> No NULL check is done for alloc_percpu() when initializing per-CPU
> nodestats. Allocation failure leads to NULL pointer dereference
> during later memset.
>
> Make function return int, check alloc_percpu() result and return
> -ENOMEM on error. The caller chain already propagates this error
> correctly.

I already applied a fix from Gregory:

https://patch.msgid.link/20260701221613.2818148-1-gourry@xxxxxxxxxx

It'll be unstreamed soon.

> Signed-off-by: Hongfu Li <lihongfu@xxxxxxxxxx>
> ---
> include/linux/memory_hotplug.h | 2 +-
> mm/memory_hotplug.c | 3 ++-
> mm/mm_init.c | 14 +++++++++++---
> 3 files changed, 14 insertions(+), 5 deletions(-)

--
Sincerely yours,
Mike.