]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/PciSioSerialDxe:add non-null pointer dereference assertion
authorFeng Tian <feng.tian@intel.com>
Thu, 17 Dec 2015 00:48:16 +0000 (00:48 +0000)
committererictian <erictian@Edk2>
Thu, 17 Dec 2015 00:48:16 +0000 (00:48 +0000)
Add assertion to make sure there doesn't exist null pointer dereference.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Feng Tian <feng.tian@intel.com>
Reviewed-by: Qiu Shumin <shumin.qiu@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19308 6f19259b-4bc3-4df7-8a09-765794883524

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