From: Nathan Chancellor Date: Mon, 23 Aug 2021 23:59:35 +0000 (+1000) Subject: mm/hugetlb: Initialize page to NULL in alloc_buddy_huge_page_with_mpol() X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=b0eb7fcac8514917091fb0d6c3e87fab53ce5df4;p=users%2Fjedix%2Flinux-maple.git mm/hugetlb: Initialize page to NULL in alloc_buddy_huge_page_with_mpol() Clang warns: mm/hugetlb.c:2162:6: warning: variable 'page' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized] if (mpol_is_preferred_many(mpol)) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ mm/hugetlb.c:2172:7: note: uninitialized use occurs here if (!page) ^~~~ mm/hugetlb.c:2162:2: note: remove the 'if' if its condition is always true if (mpol_is_preferred_many(mpol)) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ mm/hugetlb.c:2155:19: note: initialize the variable 'page' to silence this warning struct page *page; ^ = NULL 1 warning generated. Initialize page to NULL like in dequeue_huge_page_vma() so that page is not used uninitialized. Link: https://lkml.kernel.org/r/20210810200632.3812797-1-nathan@kernel.org Signed-off-by: Nathan Chancellor Cc: Mike Kravetz Cc: Feng Tang Signed-off-by: Andrew Morton Signed-off-by: Stephen Rothwell --- diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 371fec524ca0..a9ddcff4e296 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -2152,7 +2152,7 @@ static struct page *alloc_buddy_huge_page_with_mpol(struct hstate *h, struct vm_area_struct *vma, unsigned long addr) { - struct page *page; + struct page *page = NULL; struct mempolicy *mpol; gfp_t gfp_mask = htlb_alloc_mask(h); int nid;