summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Universal/Disk
diff options
context:
space:
mode:
Diffstat (limited to 'MdeModulePkg/Universal/Disk')
-rw-r--r--MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c51
1 files changed, 39 insertions, 12 deletions
diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c b/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c
index 375f07a..fa9f3e3 100644
--- a/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c
+++ b/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c
@@ -69,22 +69,35 @@ PartitionDriverBindingSupported (
EFI_DISK_IO_PROTOCOL *DiskIo;
EFI_DEV_PATH *Node;
+ //
+ // Check RemainingDevicePath validation
+ //
if (RemainingDevicePath != NULL) {
- Node = (EFI_DEV_PATH *) RemainingDevicePath;
- if (Node->DevPath.Type != MEDIA_DEVICE_PATH ||
+ //
+ // Check if RemainingDevicePath is the End of Device Path Node,
+ // if yes, go on checking other conditions
+ //
+ if (!IsDevicePathEnd (RemainingDevicePath)) {
+ //
+ // If RemainingDevicePath isn't the End of Device Path Node,
+ // check its validation
+ //
+ Node = (EFI_DEV_PATH *) RemainingDevicePath;
+ if (Node->DevPath.Type != MEDIA_DEVICE_PATH ||
Node->DevPath.SubType != MEDIA_HARDDRIVE_DP ||
- DevicePathNodeLength (&Node->DevPath) != sizeof (HARDDRIVE_DEVICE_PATH)
- ) {
+ DevicePathNodeLength (&Node->DevPath) != sizeof (HARDDRIVE_DEVICE_PATH)) {
return EFI_UNSUPPORTED;
+ }
}
}
+
//
// Open the IO Abstraction(s) needed to perform the supported test
//
Status = gBS->OpenProtocol (
ControllerHandle,
- &gEfiDevicePathProtocolGuid,
- (VOID **) &ParentDevicePath,
+ &gEfiDiskIoProtocolGuid,
+ (VOID **) &DiskIo,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -101,18 +114,18 @@ PartitionDriverBindingSupported (
//
gBS->CloseProtocol (
ControllerHandle,
- &gEfiDevicePathProtocolGuid,
+ &gEfiDiskIoProtocolGuid,
This->DriverBindingHandle,
ControllerHandle
);
//
- // Open the IO Abstraction(s) needed to perform the supported test
+ // Open the EFI Device Path protocol needed to perform the supported test
//
Status = gBS->OpenProtocol (
ControllerHandle,
- &gEfiDiskIoProtocolGuid,
- (VOID **) &DiskIo,
+ &gEfiDevicePathProtocolGuid,
+ (VOID **) &ParentDevicePath,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -124,12 +137,13 @@ PartitionDriverBindingSupported (
if (EFI_ERROR (Status)) {
return Status;
}
+
//
- // Close the I/O Abstraction(s) used to perform the supported test
+ // Close protocol, don't use device path protocol in the Support() function
//
gBS->CloseProtocol (
ControllerHandle,
- &gEfiDiskIoProtocolGuid,
+ &gEfiDevicePathProtocolGuid,
This->DriverBindingHandle,
ControllerHandle
);
@@ -181,6 +195,19 @@ PartitionDriverBindingStart (
PARTITION_DETECT_ROUTINE *Routine;
BOOLEAN MediaPresent;
+ //
+ // Check RemainingDevicePath validation
+ //
+ if (RemainingDevicePath != NULL) {
+ //
+ // Check if RemainingDevicePath is the End of Device Path Node,
+ // if yes, return EFI_SUCCESS
+ //
+ if (IsDevicePathEnd (RemainingDevicePath)) {
+ return EFI_SUCCESS;
+ }
+ }
+
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiBlockIoProtocolGuid,