diff --git a/arch/x86/mm/pat/set_memory.c b/arch/x86/mm/pat/set_memory.c index 8834c76f91c9..944e6a912fc6 100644 --- a/arch/x86/mm/pat/set_memory.c +++ b/arch/x86/mm/pat/set_memory.c @@ -305,6 +305,9 @@ static inline unsigned long fix_addr(unsigned long addr) static unsigned long __cpa_addr(struct cpa_data *cpa, unsigned long idx) { + if (WARN_ON_ONCE(!cpa->pages || !cpa->pages[idx])) + return 0; + if (cpa->flags & CPA_PAGES_ARRAY) { struct page *page = cpa->pages[idx];