mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
	x86@kernel.org
Cc: Arnd Bergmann <arnd@arndb.de>,
	Denys Vlasenko <dvlasenk@redhat.com>,
	Wei Yang <richard.weiyang@gmail.com>,
	Dan Williams <dan.j.williams@intel.com>,
	Toshi Kani <toshi.kani@hpe.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH] x86/e820: fix e820_search_gap() error handling on x86-32
Date: Wed, 11 Jan 2017 15:49:04 +0100	[thread overview]
Message-ID: <20170111144926.695369-1-arnd@arndb.de> (raw)

gcc correctly points out that on 32-bit kernels, e820_search_gap()
not finding a start now leads to pci_mem_start being set to an
uninitialized value:

arch/x86/kernel/e820.c: In function 'e820_setup_gap':
arch/x86/kernel/e820.c:641:16: error: 'gapstart' may be used uninitialized in this function [-Werror=maybe-uninitialized]

This restores the behavior from before the cleanup, defaulting
to address 0x10000000 if nothing was found.

Fixes: b4ed1d15b453 ("x86/e820: Make e820_search_gap() static and remove unused variables")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 arch/x86/kernel/e820.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index 46f2afd3577a..b2bbad6ebe4d 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -626,14 +626,16 @@ __init void e820_setup_gap(void)
 	gapsize = 0x400000;
 	found  = e820_search_gap(&gapstart, &gapsize);
 
-#ifdef CONFIG_X86_64
 	if (!found) {
+#ifdef CONFIG_X86_64
 		gapstart = (max_pfn << PAGE_SHIFT) + 1024*1024;
 		printk(KERN_ERR
 	"e820: cannot find a gap in the 32bit address range\n"
 	"e820: PCI devices with unassigned 32bit BARs may break!\n");
-	}
+#else
+		gapstart = 0x10000000;
 #endif
+	}
 
 	/*
 	 * e820_reserve_resources_late protect stolen RAM already
-- 
2.9.0

             reply	other threads:[~2017-01-11 14:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-11 14:49 Arnd Bergmann [this message]
2017-01-12 10:07 ` [tip:x86/boot] x86/e820/32: Fix " tip-bot for Arnd Bergmann
2017-01-25 15:48 ` [PATCH] x86/e820: fix " Wei Yang

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=20170111144926.695369-1-arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=dan.j.williams@intel.com \
    --cc=dvlasenk@redhat.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=richard.weiyang@gmail.com \
    --cc=tglx@linutronix.de \
    --cc=toshi.kani@hpe.com \
    --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

Powered by JetHome