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

Mike Rapoport <[email protected]>
Newsgroups org.kernel.vger.linux-cxl,org.kernel.vger.linux-kernel,org.kvack.linux-mm
Message-ID <[email protected]>
On Fri, Jul 17, 2026 at 01:29:38PM +0800, Hongfu Li wrote:
> From: Hongfu Li <[email protected]>
> 
> 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/[email protected]

It'll be unstreamed soon.
 
> Signed-off-by: Hongfu Li <[email protected]>
> ---
>  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.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.