[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200703120436.4031b4ea23e28a3babca3d2d@linux-foundation.org>
Date: Fri, 3 Jul 2020 12:04:36 -0700
From: Andrew Morton <akpm@...ux-foundation.org>
To: trix@...hat.com
Cc: linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] mm: initialize return of vm_insert_pages
On Fri, 3 Jul 2020 08:53:54 -0700 trix@...hat.com wrote:
> From: Tom Rix <trix@...hat.com>
>
> clang static analysis reports a garbage return
>
> In file included from mm/memory.c:84:
> mm/memory.c:1612:2: warning: Undefined or garbage value returned to caller [core.uninitialized.UndefReturn]
> return err;
> ^~~~~~~~~~
>
> The setting of err depends on a loop executing.
> So initialize err.
>
> ...
>
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -1601,7 +1601,7 @@ int vm_insert_pages(struct vm_area_struct *vma, unsigned long addr,
> return insert_pages(vma, addr, pages, num, vma->vm_page_prot);
> #else
> unsigned long idx = 0, pgcount = *num;
> - int err;
> + int err = -EINVAL;
>
> for (; idx < pgcount; ++idx) {
> err = vm_insert_page(vma, addr + (PAGE_SIZE * idx), pages[idx]);
If a caller were to ask vm_insert_pages() to insert zero pages, I
suspect we should just return zero and set *num to zero.
Powered by blists - more mailing lists