summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg
diff options
context:
space:
mode:
authorMichael Kinney <michael.d.kinney@intel.com>2017-01-04 13:32:53 -0800
committerMichael Kinney <michael.d.kinney@intel.com>2017-01-10 11:22:02 -0800
commit7328295cb247f420e0c465c19184c13ccbed5416 (patch)
tree59a80e4b67a9e90db7b3339761fdd8f8abf4eab2 /MdeModulePkg
parent363dc42226a1d8ae02c73f9dd81da65af91b5fdd (diff)
downloadedk2-7328295cb247f420e0c465c19184c13ccbed5416.tar.gz
edk2-7328295cb247f420e0c465c19184c13ccbed5416.tar.bz2
edk2-7328295cb247f420e0c465c19184c13ccbed5416.zip
MdeModulePkg/DxeCore: Fix ASSERT() from GCD DEBUG() messages
If a BaseAddress of NULL is passed into DXE Core services CoreAllocateIoSpace() or CoreAllocateMemorySpace(), and DEBUG() messages are enabled, then a NULL pointer reference is made. The parameter check for BaseAddress is performed in the function CoreAllocateSpace() after the DEBUG() messages. A check is added in the DEBUG() messages to prevent the NULL pointer reference. This issue was found with PI SCTs with DEBUG messages enabled in the DXE Core. Cc: Feng Tian <feng.tian@intel.com> Cc: Star Zeng <star.zeng@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Michael Kinney <michael.d.kinney@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Feng Tian <feng.tian@Intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
Diffstat (limited to 'MdeModulePkg')
-rw-r--r--MdeModulePkg/Core/Dxe/Gcd/Gcd.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c
index bd7c6c6493..e008ce8c12 100644
--- a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c
+++ b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c
@@ -3,7 +3,7 @@
The GCD services are used to manage the memory and I/O regions that
are accessible to the CPU that is executing the DXE core.
-Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -1337,7 +1337,11 @@ CoreAllocateMemorySpace (
IN EFI_HANDLE DeviceHandle OPTIONAL
)
{
- DEBUG ((DEBUG_GCD, "GCD:AllocateMemorySpace(Base=%016lx,Length=%016lx)\n", *BaseAddress, Length));
+ if (BaseAddress != NULL) {
+ DEBUG ((DEBUG_GCD, "GCD:AllocateMemorySpace(Base=%016lx,Length=%016lx)\n", *BaseAddress, Length));
+ } else {
+ DEBUG ((DEBUG_GCD, "GCD:AllocateMemorySpace(Base=<NULL>,Length=%016lx)\n", Length));
+ }
DEBUG ((DEBUG_GCD, " GcdAllocateType = %a\n", mGcdAllocationTypeNames[MIN (GcdAllocateType, EfiGcdMaxAllocateType)]));
DEBUG ((DEBUG_GCD, " GcdMemoryType = %a\n", mGcdMemoryTypeNames[MIN (GcdMemoryType, EfiGcdMemoryTypeMaximum)]));
DEBUG ((DEBUG_GCD, " Alignment = %016lx\n", LShiftU64 (1, Alignment)));
@@ -1761,7 +1765,11 @@ CoreAllocateIoSpace (
IN EFI_HANDLE DeviceHandle OPTIONAL
)
{
- DEBUG ((DEBUG_GCD, "GCD:AllocateIoSpace(Base=%016lx,Length=%016lx)\n", *BaseAddress, Length));
+ if (BaseAddress != NULL) {
+ DEBUG ((DEBUG_GCD, "GCD:AllocateIoSpace(Base=%016lx,Length=%016lx)\n", *BaseAddress, Length));
+ } else {
+ DEBUG ((DEBUG_GCD, "GCD:AllocateIoSpace(Base=<NULL>,Length=%016lx)\n", Length));
+ }
DEBUG ((DEBUG_GCD, " GcdAllocateType = %a\n", mGcdAllocationTypeNames[MIN (GcdAllocateType, EfiGcdMaxAllocateType)]));
DEBUG ((DEBUG_GCD, " GcdIoType = %a\n", mGcdIoTypeNames[MIN (GcdIoType, EfiGcdIoTypeMaximum)]));
DEBUG ((DEBUG_GCD, " Alignment = %016lx\n", LShiftU64 (1, Alignment)));