Add Pointer check for NULL before referring it and remove unnecessary pointer check in AtaAtapiPassThru and Partition Drivers.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11627 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
58f8069039
commit
d0844d133b
|
@ -794,7 +794,7 @@ ErrorExit:
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Instance->TimerEvent != NULL) {
|
if ((Instance != NULL) && (Instance->TimerEvent != NULL)) {
|
||||||
gBS->CloseEvent (Instance->TimerEvent);
|
gBS->CloseEvent (Instance->TimerEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -457,13 +457,8 @@ PartitionDriverBindingStop (
|
||||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||||
);
|
);
|
||||||
|
|
||||||
if (BlockIo != NULL) {
|
|
||||||
Private = PARTITION_DEVICE_FROM_BLOCK_IO_THIS (BlockIo);
|
Private = PARTITION_DEVICE_FROM_BLOCK_IO_THIS (BlockIo);
|
||||||
} else if (BlockIo2 != NULL) {
|
|
||||||
Private = PARTITION_DEVICE_FROM_BLOCK_IO2_THIS (BlockIo2);
|
|
||||||
} else {
|
|
||||||
ASSERT (FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
Status = gBS->CloseProtocol (
|
Status = gBS->CloseProtocol (
|
||||||
ControllerHandle,
|
ControllerHandle,
|
||||||
|
@ -1008,19 +1003,22 @@ PartitionInstallChildHandle (
|
||||||
Private->ParentBlockIo2 = ParentBlockIo2;
|
Private->ParentBlockIo2 = ParentBlockIo2;
|
||||||
Private->DiskIo = ParentDiskIo;
|
Private->DiskIo = ParentDiskIo;
|
||||||
|
|
||||||
if (Private->ParentBlockIo != NULL) {
|
//
|
||||||
|
// Set the BlockIO into Private Data.
|
||||||
|
//
|
||||||
Private->BlockIo.Revision = ParentBlockIo->Revision;
|
Private->BlockIo.Revision = ParentBlockIo->Revision;
|
||||||
|
|
||||||
Private->BlockIo.Media = &Private->Media;
|
Private->BlockIo.Media = &Private->Media;
|
||||||
CopyMem (Private->BlockIo.Media, ParentBlockIo->Media, sizeof (EFI_BLOCK_IO_MEDIA));
|
CopyMem (Private->BlockIo.Media, ParentBlockIo->Media, sizeof (EFI_BLOCK_IO_MEDIA));
|
||||||
|
|
||||||
|
|
||||||
Private->BlockIo.Reset = PartitionReset;
|
Private->BlockIo.Reset = PartitionReset;
|
||||||
Private->BlockIo.ReadBlocks = PartitionReadBlocks;
|
Private->BlockIo.ReadBlocks = PartitionReadBlocks;
|
||||||
Private->BlockIo.WriteBlocks = PartitionWriteBlocks;
|
Private->BlockIo.WriteBlocks = PartitionWriteBlocks;
|
||||||
Private->BlockIo.FlushBlocks = PartitionFlushBlocks;
|
Private->BlockIo.FlushBlocks = PartitionFlushBlocks;
|
||||||
}
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Set the BlockIO2 into Private Data.
|
||||||
|
//
|
||||||
if (Private->ParentBlockIo2 != NULL) {
|
if (Private->ParentBlockIo2 != NULL) {
|
||||||
Private->BlockIo2.Media = &Private->Media2;
|
Private->BlockIo2.Media = &Private->Media2;
|
||||||
CopyMem (Private->BlockIo2.Media, ParentBlockIo2->Media, sizeof (EFI_BLOCK_IO_MEDIA));
|
CopyMem (Private->BlockIo2.Media, ParentBlockIo2->Media, sizeof (EFI_BLOCK_IO_MEDIA));
|
||||||
|
@ -1036,7 +1034,7 @@ PartitionInstallChildHandle (
|
||||||
Private->Media.LastBlock = DivU64x32 (
|
Private->Media.LastBlock = DivU64x32 (
|
||||||
MultU64x32 (
|
MultU64x32 (
|
||||||
End - Start + 1,
|
End - Start + 1,
|
||||||
(ParentBlockIo != NULL) ? ParentBlockIo->Media->BlockSize : ParentBlockIo2->Media->BlockSize
|
ParentBlockIo->Media->BlockSize
|
||||||
),
|
),
|
||||||
BlockSize
|
BlockSize
|
||||||
) - 1;
|
) - 1;
|
||||||
|
@ -1085,8 +1083,7 @@ PartitionInstallChildHandle (
|
||||||
// here.
|
// here.
|
||||||
//
|
//
|
||||||
Private->Handle = NULL;
|
Private->Handle = NULL;
|
||||||
if ((Private->ParentBlockIo != NULL) &&
|
if ((Private->ParentBlockIo2 != NULL) &&
|
||||||
(Private->ParentBlockIo2 != NULL) &&
|
|
||||||
(Private->ParentBlockIo2->Media->BlockSize == BlockSize)
|
(Private->ParentBlockIo2->Media->BlockSize == BlockSize)
|
||||||
) {
|
) {
|
||||||
Status = gBS->InstallMultipleProtocolInterfaces (
|
Status = gBS->InstallMultipleProtocolInterfaces (
|
||||||
|
@ -1102,7 +1099,6 @@ PartitionInstallChildHandle (
|
||||||
NULL
|
NULL
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
if (Private->ParentBlockIo != NULL) {
|
|
||||||
Status = gBS->InstallMultipleProtocolInterfaces (
|
Status = gBS->InstallMultipleProtocolInterfaces (
|
||||||
&Private->Handle,
|
&Private->Handle,
|
||||||
&gEfiDevicePathProtocolGuid,
|
&gEfiDevicePathProtocolGuid,
|
||||||
|
@ -1114,21 +1110,6 @@ PartitionInstallChildHandle (
|
||||||
NULL
|
NULL
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (Private->ParentBlockIo2 != NULL &&
|
|
||||||
Private->ParentBlockIo2->Media->BlockSize == BlockSize
|
|
||||||
) {
|
|
||||||
Status = gBS->InstallMultipleProtocolInterfaces (
|
|
||||||
&Private->Handle,
|
|
||||||
&gEfiDevicePathProtocolGuid,
|
|
||||||
Private->DevicePath,
|
|
||||||
&gEfiBlockIo2ProtocolGuid,
|
|
||||||
&Private->BlockIo2,
|
|
||||||
Private->EspGuid,
|
|
||||||
NULL,
|
|
||||||
NULL
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!EFI_ERROR (Status)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in New Issue