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

Ranbir Singh via groups.io posted 1 patch 1 year, 4 months ago
Failed in applying to current master (apply log)
MdeModulePkg/Core/Dxe/Gcd/Gcd.c | 4 ++++
1 file changed, 4 insertions(+)
[edk2-devel] [PATCH] MdeModulePkg/Core/Dxe: Fix FORWARD_NULL Coverity issues
Posted by Ranbir Singh via groups.io 1 year, 4 months ago
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


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#97918): https://edk2.groups.io/g/devel/message/97918
Mute This Topic: https://groups.io/mt/96046039/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-