From b22bccf4d4a35505d81e7b065bc2f01d65da5a1a Mon Sep 17 00:00:00 2001 From: Nico Pache Date: Thu, 10 Feb 2022 19:55:28 +0800 Subject: [PATCH] mm/page_alloc.c: fix 'zone_id' may be used uninitialized in this function warning mainline inclusion from mainline-v5.15-rc1 commit b346075fcf5dda7f9e9ae671703aae60e8a94564 category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I4S7MA CVE: NA -------------------------------- When compiling with -Werror, cc1 will warn that 'zone_id' may be used uninitialized in this function warning. Initialize the zone_id as 0. Its safe to assume that if the code reaches this point it has at least one numa node with memory, so no need for an assertion before init_unavilable_range. Link: https://lkml.kernel.org/r/20210716210336.1114114-1-npache@redhat.com Fixes: 122e093c1734 ("mm/page_alloc: fix memory map initialization for descending nodes") Signed-off-by: Nico Pache Cc: Mike Rapoport Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Ma Wupeng Reviewed-by: Kefeng Wang 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 e078e3acb3de..3791bdc958bd 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -6510,7 +6510,7 @@ void __init __weak memmap_init(void) { unsigned long start_pfn, end_pfn; unsigned long hole_pfn = 0; - int i, j, zone_id, nid; + int i, j, zone_id = 0, nid; for_each_mem_pfn_range(i, MAX_NUMNODES, &start_pfn, &end_pfn, &nid) { struct pglist_data *node = NODE_DATA(nid); -- GitLab