[edk2-devel] [PATCH v1 1/5] MdeModulePkg/Core/Dxe: Fix FORWARD_NULL Coverity issues

Ranbir Singh rsingh at ventanamicro.com
Tue Sep 26 06:39:54 UTC 2023


From: Ranbir Singh <Ranbir.Singh3 at Dell.com>

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

Cc: Dandan Bi <dandan.bi at intel.com>
Cc: Liming Gao <gaoliming at byosoft.com.cn>
Co-authored-by: Veeresh Sangolli <veeresh.sangolli at dellteam.com>
Signed-off-by: Ranbir Singh <Ranbir.Singh3 at Dell.com>
Signed-off-by: Ranbir Singh <rsingh at ventanamicro.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 792cd2e0af23..39fa2adf9366 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.34.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#109060): https://edk2.groups.io/g/devel/message/109060
Mute This Topic: https://groups.io/mt/101590754/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-




More information about the edk2-devel-archive mailing list