diff options
author | Andrey Ryabinin <aryabinin@virtuozzo.com> | 2019-04-26 08:23:58 +0300 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-04-26 19:18:05 +0300 |
commit | 8139ad043d632c0e9e12d760068a7a8e91659aa1 (patch) | |
tree | 0f1168febb3f2741513726bd7832a419147cde35 /mm | |
parent | ee8ab0eeb49bd3982090c8f14dc9cc65bcd13c5c (diff) | |
download | linux-8139ad043d632c0e9e12d760068a7a8e91659aa1.tar.xz |
mm/page_alloc.c: avoid potential NULL pointer dereference
ac.preferred_zoneref->zone passed to alloc_flags_nofragment() can be NULL.
'zone' pointer unconditionally derefernced in alloc_flags_nofragment().
Bail out on NULL zone to avoid potential crash. Currently we don't see
any crashes only because alloc_flags_nofragment() has another bug which
allows compiler to optimize away all accesses to 'zone'.
Link: http://lkml.kernel.org/r/20190423120806.3503-1-aryabinin@virtuozzo.com
Fixes: 6bb154504f8b ("mm, page_alloc: spread allocations across zones before introducing fragmentation")
Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Acked-by: Mel Gorman <mgorman@techsingularity.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/page_alloc.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index d167c48d913c..9992ca7f29f1 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3432,6 +3432,9 @@ alloc_flags_nofragment(struct zone *zone, gfp_t gfp_mask) alloc_flags |= ALLOC_KSWAPD; #ifdef CONFIG_ZONE_DMA32 + if (!zone) + return alloc_flags; + if (zone_idx(zone) != ZONE_NORMAL) goto out; |