Re: [PATCH linux-next] mm/hugetlb: fix warning inalloc_huge_page/dequeue_huge_page_vma

From: Andrew Morton
Date: Tue Apr 17 2012 - 16:57:25 EST


On Tue, 17 Apr 2012 16:28:19 +0400
Konstantin Khlebnikov <khlebnikov@xxxxxxxxxx> wrote:

> This patch fixes gcc warning (and bug?) introduced in linux-next commit cc9a6c877
> ("cpuset: mm: reduce large amounts of memory barrier related damage v3")
>
> Local variable "page" can be uninitialized if nodemask from vma policy does not
> intersects with nodemask from cpuset. Even if it wouldn't happens it's better to
> initialize this variable explicitly than to introduce kernel oops on weird corner case.
>
> mm/hugetlb.c: In function ___alloc_huge_page___:
> mm/hugetlb.c:1135:5: warning: ___page___ may be used uninitialized in this function
>
> ...
>
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -532,7 +532,7 @@ static struct page *dequeue_huge_page_vma(struct hstate *h,
> struct vm_area_struct *vma,
> unsigned long address, int avoid_reserve)
> {
> - struct page *page;
> + struct page *page = NULL;
> struct mempolicy *mpol;
> nodemask_t *nodemask;
> struct zonelist *zonelist;

hm, that's a pretty blatant use-uninitialised bug. I wonder why so few
gcc versions report it. Mine doesn't.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/