]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm/hugetlb: Initialize page to NULL in alloc_buddy_huge_page_with_mpol()
authorNathan Chancellor <nathan@kernel.org>
Mon, 23 Aug 2021 23:59:35 +0000 (09:59 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Wed, 25 Aug 2021 23:34:15 +0000 (09:34 +1000)
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 <nathan@kernel.org>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Feng Tang <feng.tang@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
mm/hugetlb.c

index 371fec524ca0dc58c39ae45cbcd9b37f9d43bce4..a9ddcff4e296946fa85e7039a49735aa28e88377 100644 (file)
@@ -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;