Skip to contentSkip to conversation

x86: check for ioremap() failure in copy_oldmem_page()

PATCH Applied Akinobu Mita 2 participants 3 messages Sep 21, 2008 – Sep 22, 2008 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: check for ioremap() failure in copy_oldmem_page()

Add a check for ioremap() failure in copy_oldmem_page(). This patch also includes small coding style fixes.

Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
---
 arch/x86/kernel/crash_dump_64.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
arch/x86/kernel/crash_dump_64.c +4 -2
Index: 2.6-git/arch/x86/kernel/crash_dump_64.c
===================================================================
@@ -33,14 +33,16 @@ ssize_t copy_oldmem_page(unsigned long p
 		return 0;
 
 	vaddr = ioremap(pfn << PAGE_SHIFT, PAGE_SIZE);
+	if (!vaddr)
+		return -ENOMEM;
 
 	if (userbuf) {
-		if (copy_to_user(buf, (vaddr + offset), csize)) {
+		if (copy_to_user(buf, vaddr + offset, csize)) {
 			iounmap(vaddr);
 			return -EFAULT;
 		}
 	} else
-	memcpy(buf, (vaddr + offset), csize);
+		memcpy(buf, vaddr + offset, csize);
 
 	iounmap(vaddr);
 	return csize;
Applied
#1 lore raw
Quoted 4 lines · Akinobu Mita

Add a check for ioremap() failure in copy_oldmem_page(). This patch also includes small coding style fixes.

applied to tip/x86/crashdump, thanks!

I'm curious, have you found this bug via the fault-injection framework, or via code review?

Ingo

#2 lore raw

2008/9/22 Ingo Molnar <[email protected]>:

Quoted 6 lines · Akinobu Mita
Quoted 4 lines

Add a check for ioremap() failure in copy_oldmem_page(). This patch also includes small coding style fixes.

Quoted 6 lines
Quoted 1 line

applied to tip/x86/crashdump, thanks!

I'm curious, have you found this bug via the fault-injection framework, or via code review?

I found it via code review.
But I forgot why I was looking at crash_dump_64.c...