[edk2-devel] [PATCH] MdeModulePkg/Bus/Pci/PciBusDxe: Fix NULL_RETURNS Coverity issue

Ranbir Singh via groups.io posted 1 patch 1 year, 4 months ago
Failed in applying to current master (apply log)
MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c | 5 +++++
1 file changed, 5 insertions(+)
[edk2-devel] [PATCH] MdeModulePkg/Bus/Pci/PciBusDxe: Fix NULL_RETURNS Coverity issue
Posted by Ranbir Singh via groups.io 1 year, 4 months ago
The function StartPciDevices has a check

ASSERT (RootBridge != NULL);

but this comes into play only in DEBUG mode. In Release mode, there
is no handling if the RootBridge value is NULL and the code proceeds
to unconditionally dereference "RootBridge" which will lead to CRASH.

Hence, for safety add NULL pointer checks always and return
EFI_NOT_READY if RootBridge value is NULL which is one of the return
values as mentioned in the function description header.

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4240
Signed-off-by: Ranbir Singh <Ranbir.Singh3@Dell.com>
---
MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c
index 581e9075ad..f43f10325f 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c
@@ -773,6 +773,11 @@ StartPciDevices (

RootBridge = GetRootBridgeByHandle (Controller);
ASSERT (RootBridge != NULL);
+
+  if (RootBridge == NULL) {
+    return EFI_NOT_READY;
+  }
+
ThisHostBridge = RootBridge->PciRootBridgeIo->ParentHandle;

CurrentLink = mPciDevicePool.ForwardLink;
--
2.36.1.windows.1


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