mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: WANG Chao <chaowang@redhat.com>
To: "H. Peter Anvin" <hpa@zytor.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>,
	x86@kernel.org (maintainer:X86 ARCHITECTURE...),
	Andrew Morton <akpm@linux-foundation.org>,
	Grygorii Strashko <grygorii.strashko@ti.com>,
	Pavel Machek <pavel@ucw.cz>, David Rientjes <rientjes@google.com>,
	"Lee, Chun-Yi" <joeyli.kernel@gmail.com>,
	Xishi Qiu <qiuxishi@huawei.com>,
	linux-kernel@vger.kernel.org (open list:X86 ARCHITECTURE...)
Subject: [PATCH] x86, e820: clean up around sanitize_e820_map()
Date: Wed,  7 Jan 2015 11:37:38 +0800	[thread overview]
Message-ID: <1420601859-18439-1-git-send-email-chaowang@redhat.com> (raw)

The argument 3 of sanitize_e820_map() will only update upon a successful
sanitization. Some of the callers may not be aware of this in the past.
Now clean up these callers.

Signed-off-by: WANG Chao <chaowang@redhat.com>
---
 arch/x86/kernel/e820.c | 22 ++++++----------------
 1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index dd2f07a..ae70de8 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -185,7 +185,7 @@ void __init e820_print_map(char *who)
  *
  * The integer pointed to by pnr_map must be valid on entry (the
  * current number of valid entries located at biosmap) and will
- * be updated on return, with the new number of valid entries
+ * only be updated on return 0, with the new number of valid entries
  * (something no more than max_nr_map.)
  *
  * The return value from sanitize_e820_map() is zero if it
@@ -561,23 +561,15 @@ u64 __init e820_remove_range(u64 start, u64 size, unsigned old_type,
 
 void __init update_e820(void)
 {
-	u32 nr_map;
-
-	nr_map = e820.nr_map;
-	if (sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &nr_map))
+	if (sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map))
 		return;
-	e820.nr_map = nr_map;
 	printk(KERN_INFO "e820: modified physical RAM map:\n");
 	e820_print_map("modified");
 }
 static void __init update_e820_saved(void)
 {
-	u32 nr_map;
-
-	nr_map = e820_saved.nr_map;
-	if (sanitize_e820_map(e820_saved.map, ARRAY_SIZE(e820_saved.map), &nr_map))
-		return;
-	e820_saved.nr_map = nr_map;
+	sanitize_e820_map(e820_saved.map, ARRAY_SIZE(e820_saved.map),
+				&e820_saved.nr_map);
 }
 #define MAX_GAP_END 0x100000000ull
 /*
@@ -898,11 +890,9 @@ early_param("memmap", parse_memmap_opt);
 void __init finish_e820_parsing(void)
 {
 	if (userdef) {
-		u32 nr = e820.nr_map;
-
-		if (sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &nr) < 0)
+		if (sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map),
+					&e820.nr_map) < 0)
 			early_panic("Invalid user supplied memory map");
-		e820.nr_map = nr;
 
 		printk(KERN_INFO "e820: user-defined physical RAM map:\n");
 		e820_print_map("user");
-- 
2.1.0


             reply	other threads:[~2015-01-07  3:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-07  3:37 WANG Chao [this message]
2015-01-21 22:51 ` David Rientjes
2015-01-22  2:25   ` WANG Chao
2015-01-23 15:18 ` [tip:x86/mm] x86, e820: Clean up sanitize_e820_map() users tip-bot for WANG Chao

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=1420601859-18439-1-git-send-email-chaowang@redhat.com \
    --to=chaowang@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=grygorii.strashko@ti.com \
    --cc=hpa@zytor.com \
    --cc=joeyli.kernel@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pavel@ucw.cz \
    --cc=qiuxishi@huawei.com \
    --cc=rientjes@google.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.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®