public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] MdeModulePkg/Core: fix an issue of potential NULL pointer access
@ 2018-10-29  8:21 Jian J Wang
  2018-10-29  8:41 ` Wu, Hao A
  2018-10-30  0:53 ` Zeng, Star
  0 siblings, 2 replies; 3+ messages in thread
From: Jian J Wang @ 2018-10-29  8:21 UTC (permalink / raw)
  To: edk2-devel; +Cc: Hao Wu, Star Zeng

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1286

This issue is introduced by bb685071c2602cf786ea84c69bbebf2158194a38.

The *MemorySpaceMap assigned with NULL (line 1710) value might be
accessed (line 1726/1730) without any sanity check. Although it won't
happen in practice because of line 1722, we still need to add check
against NULL to make static code analyzer happy.

1710  *MemorySpaceMap       = NULL;
....  ...
1722  if (DescriptorCount == *NumberOfDescriptors) {
....  ...
1726    Descriptor = *MemorySpaceMap;
....  ...
1730        BuildMemoryDescriptor (Descriptor, Entry);

Tests:
  Pass build and boot to shell.

Cc: Hao Wu <hao.a.wu@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
---
 MdeModulePkg/Core/Dxe/Gcd/Gcd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c
index 8bbdf7129f..a76d2db73c 100644
--- a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c
+++ b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c
@@ -1719,7 +1719,7 @@ CoreGetMemorySpaceMap (
     // AllocatePool() called below has to be running outside the GCD lock.
     //
     DescriptorCount = CoreCountGcdMapEntry (&mGcdMemorySpaceMap);
-    if (DescriptorCount == *NumberOfDescriptors) {
+    if (DescriptorCount == *NumberOfDescriptors && *MemorySpaceMap != NULL) {
       //
       // Fill in the MemorySpaceMap if no memory space map change.
       //
-- 
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-10-30  0:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-29  8:21 [PATCH] MdeModulePkg/Core: fix an issue of potential NULL pointer access Jian J Wang
2018-10-29  8:41 ` Wu, Hao A
2018-10-30  0:53 ` Zeng, Star

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox