summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Bus
diff options
context:
space:
mode:
authorFeng Tian <feng.tian@intel.com>2015-12-17 15:02:17 +0000
committervanjeff <vanjeff@Edk2>2015-12-17 15:02:17 +0000
commit4b71020adbcba630b37b86b920d98e40f0eb25df (patch)
tree99547628c76a4d7b6e1f1a775fb173b8290b2db9 /MdeModulePkg/Bus
parent69b6a5c34ac3775ffecb7d1a6acab04e55edb086 (diff)
downloadedk2-platforms-4b71020adbcba630b37b86b920d98e40f0eb25df.tar.xz
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.tian@intel.com> Reviewed-by: Qiu Shumin <shumin.qiu@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/branches/UDK2015@19322 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Bus')
-rw-r--r--MdeModulePkg/Bus/Pci/PciSioSerialDxe/Serial.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/MdeModulePkg/Bus/Pci/PciSioSerialDxe/Serial.c b/MdeModulePkg/Bus/Pci/PciSioSerialDxe/Serial.c
index 7fc053578d..e8cefecd8d 100644
--- a/MdeModulePkg/Bus/Pci/PciSioSerialDxe/Serial.c
+++ b/MdeModulePkg/Bus/Pci/PciSioSerialDxe/Serial.c
@@ -870,6 +870,7 @@ SerialControllerDriverStart (
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 @@ SerialControllerDriverStart (
// 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 @@ SerialControllerDriverStart (
//
// Re-use the PciDeviceInfo stored in existing children.
//
+ ASSERT ((SerialDevices != NULL) && (SerialDevices[0] != NULL));
PciDeviceInfo = SerialDevices[0]->PciDeviceInfo;
ASSERT (PciDeviceInfo != NULL);
}