]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Pci/PciSioSerialDxe/Serial.c
MdeModulePkg/PciSioSerialDxe:add non-null pointer dereference assertion
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / PciSioSerialDxe / Serial.c
index 7fc053578d7d754fc1693040a654e306f5bf1274..e8cefecd8d2d810dc740565ef1d659d4f53d5291 100644 (file)
@@ -870,6 +870,7 @@ SerialControllerDriverStart (
   if ((SerialDeviceCount != 0) && (RemainingDevicePath != NULL)) {\r
     Uart = (UART_DEVICE_PATH *) SkipControllerDevicePathNode (RemainingDevicePath, &ContainsControllerNode, &ControllerNumber);\r
     for (Index = 0; Index < SerialDeviceCount; Index++) {\r
+      ASSERT ((SerialDevices != NULL) && (SerialDevices[Index] != NULL));\r
       if ((!SerialDevices[Index]->ContainsControllerNode && !ContainsControllerNode) ||\r
           (SerialDevices[Index]->ContainsControllerNode && ContainsControllerNode && SerialDevices[Index]->Instance == ControllerNumber)\r
           ) {\r
@@ -963,6 +964,7 @@ SerialControllerDriverStart (
         // Restore the PCI attributes when all children is destroyed (PciDeviceInfo->ChildCount == 0).\r
         //\r
         PciDeviceInfo = AllocatePool (sizeof (PCI_DEVICE_INFO));\r
+        ASSERT (PciDeviceInfo != NULL);\r
         PciDeviceInfo->ChildCount = 0;\r
         PciDeviceInfo->PciIo = ParentIo.PciIo;\r
         Status = ParentIo.PciIo->Attributes (\r
@@ -993,6 +995,7 @@ SerialControllerDriverStart (
         //\r
         // Re-use the PciDeviceInfo stored in existing children.\r
         //\r
+        ASSERT ((SerialDevices != NULL) && (SerialDevices[0] != NULL));\r
         PciDeviceInfo = SerialDevices[0]->PciDeviceInfo;\r
         ASSERT (PciDeviceInfo != NULL);\r
       }\r