diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 1678431fb4c42a9eacb862cbd41d92169c148ea5..d04211f0ef0b142c9625b47e4115e0515804590e 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -5740,6 +5740,18 @@ void *page_frag_alloc_align(struct page_frag_cache *nc, /* 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--;