]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg: QemuVideoDxe: serialize Start() against callbacks
authorLaszlo Ersek <lersek@redhat.com>
Sat, 22 Mar 2014 07:13:44 +0000 (07:13 +0000)
committerjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>
Sat, 22 Mar 2014 07:13:44 +0000 (07:13 +0000)
If Start() succeeds, the callback is only executed when the setup is
complete (on the stack of RestoreTPL()), rather than on the stack of
InstallMultipleProtocolInterfaces(), when the driver setup may yet be
theoretically incomplete.

If Start() fails, the protocol interface will have been uninstalled
(rolled back) by the time the callback runs (again, on the stack of
RestoreTPL()). Since protocol notification callbacks begin with locating
the protocol interface in question, such attempts to locate will fail
immediately and save some work in the callback.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15371 6f19259b-4bc3-4df7-8a09-765794883524

OvmfPkg/QemuVideoDxe/Driver.c

index e71af6e8503713cea3996772653ea65c023517f3..c44b8b2603008634be3c0f49699cccbaed8c4339 100644 (file)
@@ -170,6 +170,7 @@ QemuVideoControllerDriverStart (
   IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
   )\r
 {\r
+  EFI_TPL                           OldTpl;\r
   EFI_STATUS                        Status;\r
   QEMU_VIDEO_PRIVATE_DATA           *Private;\r
   EFI_DEVICE_PATH_PROTOCOL          *ParentDevicePath;\r
@@ -178,12 +179,15 @@ QemuVideoControllerDriverStart (
   QEMU_VIDEO_CARD                   *Card;\r
   EFI_PCI_IO_PROTOCOL               *ChildPciIo;\r
 \r
+  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
+\r
   //\r
   // Allocate Private context data for GOP inteface.\r
   //\r
   Private = AllocateZeroPool (sizeof (QEMU_VIDEO_PRIVATE_DATA));\r
   if (Private == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
+    Status = EFI_OUT_OF_RESOURCES;\r
+    goto RestoreTpl;\r
   }\r
 \r
   //\r
@@ -394,6 +398,7 @@ QemuVideoControllerDriverStart (
     goto UninstallGop;\r
   }\r
 \r
+  gBS->RestoreTPL (OldTpl);\r
   return EFI_SUCCESS;\r
 \r
 UninstallGop:\r
@@ -424,6 +429,9 @@ ClosePciIo:
 FreePrivate:\r
   FreePool (Private);\r
 \r
+RestoreTpl:\r
+  gBS->RestoreTPL (OldTpl);\r
+\r
   return Status;\r
 }\r
 \r