From 8c4566b5232290b4544b1a8ff65ecea9f0465dd5 Mon Sep 17 00:00:00 2001 From: Yanfei Xu Date: Sat, 4 Sep 2021 17:23:04 +0800 Subject: [PATCH] mm/page_alloc: correct return value when failing at preparing mainline inclusion from mainline-5.14-rc2 commit e5c15cea339115edf99dc92282865f173cf84510 category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I3ZVL2 CVE: NA Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e5c15cea339115edf99dc92282865f173cf84510 ------------------------------------------------- If the array passed in is already partially populated, we should return "nr_populated" even failing at preparing arguments stage. Link: https://lkml.kernel.org/r/20210713152100.10381-3-mgorman@techsingularity.net Signed-off-by: Yanfei Xu Signed-off-by: Mel Gorman Link: https://lore.kernel.org/r/20210709102855.55058-1-yanfei.xu@windriver.com Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds (cherry picked from commit e5c15cea339115edf99dc92282865f173cf84510) Signed-off-by: Yongqiang Liu Reviewed-by: tong tiangen Signed-off-by: Zheng Zengkai --- mm/page_alloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 12a7a81996d3..090c23060be8 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -4987,7 +4987,7 @@ unsigned long __alloc_pages_bulk(gfp_t gfp, int preferred_nid, gfp &= gfp_allowed_mask; alloc_gfp = gfp; if (!prepare_alloc_pages(gfp, 0, preferred_nid, nodemask, &ac, &alloc_gfp, &alloc_flags)) - return 0; + return nr_populated; gfp = alloc_gfp; /* Find an allowed local zone that meets the low watermark. */ -- GitLab