From: Andrew Morton <akpm@linux-foundation.org>
To: trix@redhat.com
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] mm: initialize return of vm_insert_pages
Date: Fri, 3 Jul 2020 12:04:36 -0700 [thread overview]
Message-ID: <20200703120436.4031b4ea23e28a3babca3d2d@linux-foundation.org> (raw)
In-Reply-To: <20200703155354.29132-1-trix@redhat.com>
On Fri, 3 Jul 2020 08:53:54 -0700 trix@redhat.com wrote:
> From: Tom Rix <trix@redhat.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.
next prev parent reply other threads:[~2020-07-03 19:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-03 15:53 [PATCH v2] mm: initialize return of vm_insert_pages trix
2020-07-03 19:04 ` Andrew Morton [this message]
2020-07-03 19:23 ` Tom Rix
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200703120436.4031b4ea23e28a3babca3d2d@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=trix@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).