Skip to content
Commit 82f0b6f0 authored by Waiman Long's avatar Waiman Long Committed by Andrew Morton
Browse files

mm: prevent derefencing NULL ptr in pfn_section_valid()

Commit 5ec8e8ea ("mm/sparsemem: fix race in accessing
memory_section->usage") changed pfn_section_valid() to add a READ_ONCE()
call around "ms->usage" to fix a race with section_deactivate() where
ms->usage can be cleared.  The READ_ONCE() call, by itself, is not enough
to prevent NULL pointer dereference.  We need to check its value before
dereferencing it.

Link: https://lkml.kernel.org/r/20240626001639.1350646-1-longman@redhat.com
Fixes: 5ec8e8ea

 ("mm/sparsemem: fix race in accessing memory_section->usage")
Signed-off-by: default avatarWaiman Long <longman@redhat.com>
Cc: Charan Teja Kalla <quic_charante@quicinc.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent fa2690af
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment