]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/VirtioBlkDxe/VirtioBlk.c
OvmfPkg: VirtioNetDxe: driver binding
[mirror_edk2.git] / OvmfPkg / VirtioBlkDxe / VirtioBlk.c
index 199b9dd0ae895c86b894b0f6da3515a338c98555..b2bfcdf7b72aecb2c66613b77933bc8c8aee772c 100644 (file)
@@ -944,18 +944,32 @@ VirtioBlkDriverBindingStop (
   IN EFI_HANDLE                  *ChildHandleBuffer\r
   )\r
 {\r
-  VBLK_DEV   *Dev;\r
-  EFI_STATUS Status;\r
+  EFI_STATUS            Status;\r
+  EFI_BLOCK_IO_PROTOCOL *BlockIo;\r
+  VBLK_DEV              *Dev;\r
 \r
-  Dev = VIRTIO_BLK_FROM_BLOCK_IO (This);\r
+  Status = gBS->OpenProtocol (\r
+                  DeviceHandle,                  // candidate device\r
+                  &gEfiBlockIoProtocolGuid,      // retrieve the BlockIo iface\r
+                  (VOID **)&BlockIo,             // target pointer\r
+                  This->DriverBindingHandle,     // requestor driver identity\r
+                  DeviceHandle,                  // requesting lookup for dev.\r
+                  EFI_OPEN_PROTOCOL_GET_PROTOCOL // lookup only, no ref. added\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  Dev = VIRTIO_BLK_FROM_BLOCK_IO (BlockIo);\r
 \r
   //\r
-  // If DriverBindingStop() is called with the driver instance still in use,\r
-  // or any of the parameters are invalid, we've caught a bug.\r
+  // Handle Stop() requests for in-use driver instances gracefully.\r
   //\r
   Status = gBS->UninstallProtocolInterface (DeviceHandle,\r
                   &gEfiBlockIoProtocolGuid, &Dev->BlockIo);\r
-  ASSERT (Status == EFI_SUCCESS);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
 \r
   VirtioBlkUninit (Dev);\r
 \r