The functions CoreConvertSpace and CoreAllocateSpace in
 
    MdeModulePkg/Core/Dxe/Gcd/Gcd.c has
 
    ASSERT (FALSE); at lines 755 and 1155 which gets hit when
 
Operation neither include GCD_MEMORY_SPACE_OPERATION nor include
GCD_IO_SPACE_OPERATION but this comes into play only in DEBUG mode.
In Release mode, the code continues to proceed in this undesirable
case with Map variable still set to NULL and hence dereferencing
"Map" will lead to CRASH.
 
It is safer to add a debug message in this scenario and return from
the function with EFI_INVALID_PARAMETER; The existing ASSERT may be
retained or may be deleted whatever is deemed more appropriate.
 
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4219
Signed-off-by: Ranbir Singh <Ranbir.Singh3@Dell.com>
---
 MdeModulePkg/Core/Dxe/Gcd/Gcd.c | 4 ++++
 1 file changed, 4 insertions(+)
 
diff --git a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c
index 792cd2e0af..39fa2adf93 100644
--- a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c
+++ b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c
@@ -752,7 +752,9 @@ CoreConvertSpace (
     CoreAcquireGcdIoLock ();
     Map = &mGcdIoSpaceMap;
   } else {
+    DEBUG ((DEBUG_GCD, "  Status = %r\n", EFI_INVALID_PARAMETER));
     ASSERT (FALSE);
+    return EFI_INVALID_PARAMETER;
   }
 
   //
@@ -1152,7 +1154,9 @@ CoreAllocateSpace (
     CoreAcquireGcdIoLock ();
     Map = &mGcdIoSpaceMap;
   } else {
+    DEBUG ((DEBUG_GCD, "  Status = %r\n", EFI_INVALID_PARAMETER));
     ASSERT (FALSE);
+    return EFI_INVALID_PARAMETER;
   }
 
   Found     = FALSE;
--
2.36.1.windows.1