From: Joe Perches <joe@perches.com>
To: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
Brice Goglin <Brice.Goglin@inria.fr>,
Christoph Lameter <clameter@sgi.com>,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
Nick Piggin <npiggin@suse.de>, Hugh Dickins <hugh@veritas.com>,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: mm: Don't touch uninitialized variable in do_pages_stat_array()
Date: Tue, 16 Dec 2008 11:47:01 -0800 [thread overview]
Message-ID: <1229456821.20606.19.camel@localhost> (raw)
In-Reply-To: <200812161859.mBGIx1kR018513@hera.kernel.org>
On Tue, 2008-12-16 at 18:59 +0000, Linux Kernel Mailing List wrote:
> Gitweb: http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=c095adbc211f9f4e990eac7d6cb440de35e4f05f
> Commit: c095adbc211f9f4e990eac7d6cb440de35e4f05f
> Parent: a3dd15444baa9c7522c8457ab564c41219dfb44c
> Author: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
> AuthorDate: Tue Dec 16 16:06:43 2008 +0900
> Committer: Linus Torvalds <torvalds@linux-foundation.org>
> CommitDate: Tue Dec 16 08:19:23 2008 -0800
>
> mm: Don't touch uninitialized variable in do_pages_stat_array()
>
> Commit 80bba1290ab5122c60cdb73332b26d288dc8aedd removed one necessary
> variable initialization. As a result following warning happened:
>
> CC mm/migrate.o
> mm/migrate.c: In function 'sys_move_pages':
> mm/migrate.c:1001: warning: 'err' may be used uninitialized in this function
>
> More unfortunately, if find_vma() failed, kernel read uninitialized
> memory.
>
> Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
> CC: Brice Goglin <Brice.Goglin@inria.fr>
> Cc: Christoph Lameter <clameter@sgi.com>
> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
> Cc: Nick Piggin <npiggin@suse.de>
> Cc: Hugh Dickins <hugh@veritas.com>
> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
> ---
> mm/migrate.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/mm/migrate.c b/mm/migrate.c
> index d8f0766..037b096 100644
> --- a/mm/migrate.c
> +++ b/mm/migrate.c
> @@ -998,7 +998,7 @@ static void do_pages_stat_array(struct mm_struct *mm, unsigned long nr_pages,
> unsigned long addr = (unsigned long)(*pages);
> struct vm_area_struct *vma;
> struct page *page;
> - int err;
> + int err = -EFAULT;
>
> vma = find_vma(mm, addr);
> if (!vma)
> --
Perhaps this is more legible and avoids
the unnecessary assignments to err.
Signed-off-by: Joe Perches <joe@perches.com>
diff --git a/mm/migrate.c b/mm/migrate.c
index 037b096..ddfeeac 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -998,22 +998,25 @@ static void do_pages_stat_array(struct mm_struct *mm, unsigned long nr_pages,
unsigned long addr = (unsigned long)(*pages);
struct vm_area_struct *vma;
struct page *page;
- int err = -EFAULT;
+ int err;
vma = find_vma(mm, addr);
- if (!vma)
+ if (!vma) {
+ err = -EFAULT;
goto set_status;
+ }
page = follow_page(vma, addr, 0);
-
- err = PTR_ERR(page);
- if (IS_ERR(page))
+ if (IS_ERR(page)) {
+ err = PTR_ERR(page);
goto set_status;
+ }
- err = -ENOENT;
/* Use PageReserved to check for zero page */
- if (!page || PageReserved(page))
+ if (!page || PageReserved(page)) {
+ err = -ENOENT;
goto set_status;
+ }
err = page_to_nid(page);
set_status:
next parent reply other threads:[~2008-12-16 19:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <200812161859.mBGIx1kR018513@hera.kernel.org>
2008-12-16 19:47 ` Joe Perches [this message]
2008-12-16 20:35 ` Linus Torvalds
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=1229456821.20606.19.camel@localhost \
--to=joe@perches.com \
--cc=Brice.Goglin@inria.fr \
--cc=clameter@sgi.com \
--cc=hugh@veritas.com \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=kosaki.motohiro@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=npiggin@suse.de \
--cc=torvalds@linux-foundation.org \
/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
all inboxes | Powered by JetHome®