Revision: 19322
          http://sourceforge.net/p/edk2/code/19322
Author:   vanjeff
Date:     2015-12-17 15:02:17 +0000 (Thu, 17 Dec 2015)
Log Message:
-----------
MdeModulePkg/PciSioSerialDxe:add non-null pointer dereference assertion

Add assertion to make sure there doesn't exist null pointer dereference.

(Sync patch r19308 from main trunk.)

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Feng Tian <feng.t...@intel.com>
Reviewed-by: Qiu Shumin <shumin....@intel.com>

Revision Links:
--------------
    http://sourceforge.net/p/edk2/code/19308

Modified Paths:
--------------
    branches/UDK2015/MdeModulePkg/Bus/Pci/PciSioSerialDxe/Serial.c

Modified: branches/UDK2015/MdeModulePkg/Bus/Pci/PciSioSerialDxe/Serial.c
===================================================================
--- branches/UDK2015/MdeModulePkg/Bus/Pci/PciSioSerialDxe/Serial.c      
2015-12-17 14:06:52 UTC (rev 19321)
+++ branches/UDK2015/MdeModulePkg/Bus/Pci/PciSioSerialDxe/Serial.c      
2015-12-17 15:02:17 UTC (rev 19322)
@@ -870,6 +870,7 @@
   if ((SerialDeviceCount != 0) && (RemainingDevicePath != NULL)) {
     Uart = (UART_DEVICE_PATH *) SkipControllerDevicePathNode 
(RemainingDevicePath, &ContainsControllerNode, &ControllerNumber);
     for (Index = 0; Index < SerialDeviceCount; Index++) {
+      ASSERT ((SerialDevices != NULL) && (SerialDevices[Index] != NULL));
       if ((!SerialDevices[Index]->ContainsControllerNode && 
!ContainsControllerNode) ||
           (SerialDevices[Index]->ContainsControllerNode && 
ContainsControllerNode && SerialDevices[Index]->Instance == ControllerNumber)
           ) {
@@ -963,6 +964,7 @@
         // Restore the PCI attributes when all children is destroyed 
(PciDeviceInfo->ChildCount == 0).
         //
         PciDeviceInfo = AllocatePool (sizeof (PCI_DEVICE_INFO));
+        ASSERT (PciDeviceInfo != NULL);
         PciDeviceInfo->ChildCount = 0;
         PciDeviceInfo->PciIo = ParentIo.PciIo;
         Status = ParentIo.PciIo->Attributes (
@@ -993,6 +995,7 @@
         //
         // Re-use the PciDeviceInfo stored in existing children.
         //
+        ASSERT ((SerialDevices != NULL) && (SerialDevices[0] != NULL));
         PciDeviceInfo = SerialDevices[0]->PciDeviceInfo;
         ASSERT (PciDeviceInfo != NULL);
       }


------------------------------------------------------------------------------
_______________________________________________
edk2-commits mailing list
edk2-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to