MdeModulePkg/PciSioSerialDxe:add non-null pointer dereference assertion
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
This commit is contained in:
@ -870,6 +870,7 @@ SerialControllerDriverStart (
|
|||||||
if ((SerialDeviceCount != 0) && (RemainingDevicePath != NULL)) {
|
if ((SerialDeviceCount != 0) && (RemainingDevicePath != NULL)) {
|
||||||
Uart = (UART_DEVICE_PATH *) SkipControllerDevicePathNode (RemainingDevicePath, &ContainsControllerNode, &ControllerNumber);
|
Uart = (UART_DEVICE_PATH *) SkipControllerDevicePathNode (RemainingDevicePath, &ContainsControllerNode, &ControllerNumber);
|
||||||
for (Index = 0; Index < SerialDeviceCount; Index++) {
|
for (Index = 0; Index < SerialDeviceCount; Index++) {
|
||||||
|
ASSERT ((SerialDevices != NULL) && (SerialDevices[Index] != NULL));
|
||||||
if ((!SerialDevices[Index]->ContainsControllerNode && !ContainsControllerNode) ||
|
if ((!SerialDevices[Index]->ContainsControllerNode && !ContainsControllerNode) ||
|
||||||
(SerialDevices[Index]->ContainsControllerNode && ContainsControllerNode && SerialDevices[Index]->Instance == ControllerNumber)
|
(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).
|
// Restore the PCI attributes when all children is destroyed (PciDeviceInfo->ChildCount == 0).
|
||||||
//
|
//
|
||||||
PciDeviceInfo = AllocatePool (sizeof (PCI_DEVICE_INFO));
|
PciDeviceInfo = AllocatePool (sizeof (PCI_DEVICE_INFO));
|
||||||
|
ASSERT (PciDeviceInfo != NULL);
|
||||||
PciDeviceInfo->ChildCount = 0;
|
PciDeviceInfo->ChildCount = 0;
|
||||||
PciDeviceInfo->PciIo = ParentIo.PciIo;
|
PciDeviceInfo->PciIo = ParentIo.PciIo;
|
||||||
Status = ParentIo.PciIo->Attributes (
|
Status = ParentIo.PciIo->Attributes (
|
||||||
@ -993,6 +995,7 @@ SerialControllerDriverStart (
|
|||||||
//
|
//
|
||||||
// Re-use the PciDeviceInfo stored in existing children.
|
// Re-use the PciDeviceInfo stored in existing children.
|
||||||
//
|
//
|
||||||
|
ASSERT ((SerialDevices != NULL) && (SerialDevices[0] != NULL));
|
||||||
PciDeviceInfo = SerialDevices[0]->PciDeviceInfo;
|
PciDeviceInfo = SerialDevices[0]->PciDeviceInfo;
|
||||||
ASSERT (PciDeviceInfo != NULL);
|
ASSERT (PciDeviceInfo != NULL);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user