public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] MdeModulePkg/Bus/Pci/PciBusDxe: Fix NULL_RETURNS Coverity issue
@ 2023-01-04  7:29 Ranbir Singh
  0 siblings, 0 replies; only message in thread
From: Ranbir Singh @ 2023-01-04  7:29 UTC (permalink / raw)
  To: devel

[-- Attachment #1: Type: text/plain, Size: 1282 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 1826 bytes --]

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2023-01-04  7:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-04  7:29 [PATCH] MdeModulePkg/Bus/Pci/PciBusDxe: Fix NULL_RETURNS Coverity issue Ranbir Singh

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