diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 0fe1dae8b9d5..a71722b4e464 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -5600,6 +5600,18 @@ refill: /* reset page count bias and offset to start of new frag */ nc->pagecnt_bias = PAGE_FRAG_CACHE_MAX_SIZE + 1; offset = size - fragsz; + if (unlikely(offset < 0)) { + /* + * The caller is trying to allocate a fragment + * with fragsz > PAGE_SIZE but the cache isn't big + * enough to satisfy the request, this may + * happen in low memory conditions. + * We don't release the cache page because + * it could make memory pressure worse + * so we simply return NULL here. + */ + return NULL; + } } nc->pagecnt_bias--;