Reviewed-by: Qiu Shumin <[email protected]> -----Original Message----- From: edk2-devel [mailto:[email protected]] On Behalf Of Tian Feng Sent: Tuesday, December 15, 2015 8:47 AM To: [email protected] Cc: Qiu, Shumin; Tian, Feng Subject: [edk2] [patch 1/2] MdeModulePkg/PciSioSerialDxe:add non-null pointer dereference assertion
Add assertion to make sure there doesn't exist null pointer dereference. Cc: Qiu Shumin <[email protected]> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Feng Tian <[email protected]> --- MdeModulePkg/Bus/Pci/PciSioSerialDxe/Serial.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/MdeModulePkg/Bus/Pci/PciSioSerialDxe/Serial.c b/MdeModulePkg/Bus/Pci/PciSioSerialDxe/Serial.c index 7fc0535..e8cefec 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); } -- 1.9.5.msysgit.0 _______________________________________________ edk2-devel mailing list [email protected] https://lists.01.org/mailman/listinfo/edk2-devel _______________________________________________ edk2-devel mailing list [email protected] https://lists.01.org/mailman/listinfo/edk2-devel

