]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EdkModulePkg/Bus/Pci/IdeBus/Dxe/ComponentName.c
Fix component name bugs when input Controller Name is invalid
[mirror_edk2.git] / EdkModulePkg / Bus / Pci / IdeBus / Dxe / ComponentName.c
index edead729b40d5d12fe9866cc029d763dadd0d414..12673c9c92b66c8913b94e43632186d12d2dc7f5 100644 (file)
@@ -125,16 +125,13 @@ IDEBusComponentNameGetControllerName (
   IDE_BLK_IO_DEV        *IdeBlkIoDevice;\r
 \r
   //\r
-  // Get the controller context\r
+  // Make sure this driver is currently managing ControllHandle\r
   //\r
-  Status = gBS->OpenProtocol (\r
-                  ControllerHandle,\r
-                  &gEfiCallerIdGuid,\r
-                  NULL,\r
-                  gIDEBusDriverBinding.DriverBindingHandle,\r
-                  ControllerHandle,\r
-                  EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
-                  );\r
+  Status = EfiTestManagedDevice (\r
+             ControllerHandle,\r
+             gIDEBusDriverBinding.DriverBindingHandle,\r
+             &gEfiIdeControllerInitProtocolGuid\r
+             );\r
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
@@ -148,6 +145,15 @@ IDEBusComponentNameGetControllerName (
             );\r
   }\r
 \r
+  Status = EfiTestChildHandle (\r
+             ControllerHandle,\r
+             ChildHandle,\r
+             &gEfiPciIoProtocolGuid\r
+             );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
   //\r
   // Get the child context\r
   //\r