diff options
author | qianouyang <qianouyang@6f19259b-4bc3-4df7-8a09-765794883524> | 2011-05-06 07:15:41 +0000 |
---|---|---|
committer | qianouyang <qianouyang@6f19259b-4bc3-4df7-8a09-765794883524> | 2011-05-06 07:15:41 +0000 |
commit | d0844d133bf1b76abfbc83387758fdd01360334b (patch) | |
tree | 94185f7359ea077939c486ad48ded5c13ec7666f /MdeModulePkg | |
parent | 58f8069039c9e664cd1826d4ac84e73a755b034b (diff) | |
download | edk2-platforms-d0844d133bf1b76abfbc83387758fdd01360334b.tar.xz |
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
Diffstat (limited to 'MdeModulePkg')
-rw-r--r-- | MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c | 2 | ||||
-rw-r--r-- | MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c | 77 |
2 files changed, 30 insertions, 49 deletions
diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c index 3e135d74ec..526590718a 100644 --- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c +++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c @@ -794,7 +794,7 @@ ErrorExit: );
}
- if (Instance->TimerEvent != NULL) {
+ if ((Instance != NULL) && (Instance->TimerEvent != NULL)) {
gBS->CloseEvent (Instance->TimerEvent);
}
diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c b/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c index 7d194daaea..9de8312cae 100644 --- a/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c +++ b/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c @@ -457,13 +457,8 @@ PartitionDriverBindingStop ( EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
- if (BlockIo != NULL) {
- Private = PARTITION_DEVICE_FROM_BLOCK_IO_THIS (BlockIo);
- } else if (BlockIo2 != NULL) {
- Private = PARTITION_DEVICE_FROM_BLOCK_IO2_THIS (BlockIo2);
- } else {
- ASSERT (FALSE);
- }
+
+ Private = PARTITION_DEVICE_FROM_BLOCK_IO_THIS (BlockIo);
Status = gBS->CloseProtocol (
ControllerHandle,
@@ -1008,19 +1003,22 @@ PartitionInstallChildHandle ( Private->ParentBlockIo2 = ParentBlockIo2;
Private->DiskIo = ParentDiskIo;
- if (Private->ParentBlockIo != NULL) {
- Private->BlockIo.Revision = ParentBlockIo->Revision;
-
- Private->BlockIo.Media = &Private->Media;
- CopyMem (Private->BlockIo.Media, ParentBlockIo->Media, sizeof (EFI_BLOCK_IO_MEDIA));
-
+ //
+ // Set the BlockIO into Private Data.
+ //
+ Private->BlockIo.Revision = ParentBlockIo->Revision;
+
+ Private->BlockIo.Media = &Private->Media;
+ CopyMem (Private->BlockIo.Media, ParentBlockIo->Media, sizeof (EFI_BLOCK_IO_MEDIA));
- Private->BlockIo.Reset = PartitionReset;
- Private->BlockIo.ReadBlocks = PartitionReadBlocks;
- Private->BlockIo.WriteBlocks = PartitionWriteBlocks;
- Private->BlockIo.FlushBlocks = PartitionFlushBlocks;
- }
+ Private->BlockIo.Reset = PartitionReset;
+ Private->BlockIo.ReadBlocks = PartitionReadBlocks;
+ Private->BlockIo.WriteBlocks = PartitionWriteBlocks;
+ Private->BlockIo.FlushBlocks = PartitionFlushBlocks;
+ //
+ // Set the BlockIO2 into Private Data.
+ //
if (Private->ParentBlockIo2 != NULL) {
Private->BlockIo2.Media = &Private->Media2;
CopyMem (Private->BlockIo2.Media, ParentBlockIo2->Media, sizeof (EFI_BLOCK_IO_MEDIA));
@@ -1036,7 +1034,7 @@ PartitionInstallChildHandle ( Private->Media.LastBlock = DivU64x32 (
MultU64x32 (
End - Start + 1,
- (ParentBlockIo != NULL) ? ParentBlockIo->Media->BlockSize : ParentBlockIo2->Media->BlockSize
+ ParentBlockIo->Media->BlockSize
),
BlockSize
) - 1;
@@ -1085,8 +1083,7 @@ PartitionInstallChildHandle ( // here.
//
Private->Handle = NULL;
- if ((Private->ParentBlockIo != NULL) &&
- (Private->ParentBlockIo2 != NULL) &&
+ if ((Private->ParentBlockIo2 != NULL) &&
(Private->ParentBlockIo2->Media->BlockSize == BlockSize)
) {
Status = gBS->InstallMultipleProtocolInterfaces (
@@ -1101,33 +1098,17 @@ PartitionInstallChildHandle ( NULL,
NULL
);
- } else {
- if (Private->ParentBlockIo != NULL) {
- Status = gBS->InstallMultipleProtocolInterfaces (
- &Private->Handle,
- &gEfiDevicePathProtocolGuid,
- Private->DevicePath,
- &gEfiBlockIoProtocolGuid,
- &Private->BlockIo,
- Private->EspGuid,
- 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
- );
- }
+ } else {
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &Private->Handle,
+ &gEfiDevicePathProtocolGuid,
+ Private->DevicePath,
+ &gEfiBlockIoProtocolGuid,
+ &Private->BlockIo,
+ Private->EspGuid,
+ NULL,
+ NULL
+ );
}
if (!EFI_ERROR (Status)) {
|