Skip to contentSkip to conversation

x86/e820: fix e820_search_gap() error handling on x86-32

PATCH In review Arnd Bergmann 3 participants 3 messages Jan 11, 2017 – Jan 25, 2017 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/e820: fix e820_search_gap() error handling on x86-32

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")
---
 arch/x86/kernel/e820.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
arch/x86/kernel/e820.c +4 -2
index 46f2afd3577a..b2bbad6ebe4d 100644
@@ -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
Signature · 1 line
2.9.0
#1 lore raw

[tip:x86/boot] x86/e820/32: Fix e820_search_gap() error handling on x86-32

x86/e820/32: Fix e820_search_gap() error handling on x86-32
Commit-ID:  c19a5f35e315837170ee337eed21c7087ea94192
Gitweb:     http://git.kernel.org/tip/c19a5f35e315837170ee337eed21c7087ea94192
Author:     Arnd Bergmann <[email protected]>
AuthorDate: Wed, 11 Jan 2017 15:49:04 +0100
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 12 Jan 2017 09:40:06 +0100

x86/e820/32: Fix e820_search_gap() error handling on x86-32

GCC correctly points out that on 32-bit kernels, e820_search_gap() not finding a start now leads to pci_mem_start ('gapstart') 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 this cleanup:

b4ed1d15b453 ("x86/e820: Make e820_search_gap() static and remove unused variables")

... defaulting to address 0x10000000 if nothing was found.

Cc Dan Williams <[email protected]>
Cc Denys Vlasenko <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Toshi Kani <[email protected]>
Cc Wei Yang <[email protected]>
Fixes b4ed1d15b453 ("x86/e820: Make e820_search_gap() static and remove unused variables")
---
 arch/x86/kernel/e820.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
arch/x86/kernel/e820.c +4 -2
index 46f2afd..b2bbad6 100644
@@ -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 lore raw
In reply to Arnd Bergmann

You are right. Thanks :-)

Quoted 41 lines · Arnd Bergmann

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")

---
arch/x86/kernel/e820.c | 6 ++++--

1 file changed, 4 insertions(+), 2 deletions(-)
arch/x86/kernel/e820.c +4 -2
index 46f2afd3577a..b2bbad6ebe4d 100644
@@ -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
Signature · 1 line
2.9.0
Signature · 2 lines
Wei Yang
Help you, Help me