From 07515616399254e1e9d5f7664ea9c70986bf2ae3 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sat, 9 Feb 2013 19:54:29 +0800 Subject: [PATCH] Kernel/x86 - Fixed ACPICA shim possible null deref --- KernelLand/Kernel/arch/x86/acpica.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/KernelLand/Kernel/arch/x86/acpica.c b/KernelLand/Kernel/arch/x86/acpica.c index 57d7fe85..c2e5888d 100644 --- a/KernelLand/Kernel/arch/x86/acpica.c +++ b/KernelLand/Kernel/arch/x86/acpica.c @@ -94,7 +94,7 @@ ACPI_PHYSICAL_ADDRESS AcpiOsGetRootPointer(void) if( ACPI_FAILURE(rv) ) return 0; - LOG("val=%x", val); + LOG("val=0x%x", val); return val; // (Or use EFI) @@ -222,8 +222,13 @@ void *AcpiOsMapMemory(ACPI_PHYSICAL_ADDRESS PhysicalAddress, ACPI_SIZE Length) Uint ofs = PhysicalAddress & (PAGE_SIZE-1); int npages = (ofs + Length + (PAGE_SIZE-1)) / PAGE_SIZE; - void *rv = ((char*)MM_MapHWPages(PhysicalAddress, npages)) + ofs; + char *maploc = (void*)MM_MapHWPages(PhysicalAddress, npages); + if(!maploc) { + LOG("Mapping %P+0x%x failed", PhysicalAddress, Length); + return NULL; + } // MM_DumpTables(0, -1); + void *rv = maploc + ofs; LOG("Map (%P+%i pg) to %p", PhysicalAddress, npages, rv); return rv; } -- 2.20.1