]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c
add check for NULL pointer reference.
[mirror_edk2.git] / MdeModulePkg / Universal / Console / ConSplitterDxe / ConSplitter.c
index cb993d7b6694cb5c689610d0976d6304acd8f2a7..8c4395c3a77d6939aeff4f7e02f82c3e7a00bb1f 100644 (file)
@@ -12,8 +12,8 @@
   These 3 virtual handles would be installed on gST.\r
 \r
   Each virtual handle, that supports the Console I/O protocol, will be produced\r
-  in the driver entry point. The virtual handle are added on driver entry and \r
-  never removed. Such design ensures sytem function well during none console \r
+  in the driver entry point. The virtual handle are added on driver entry and\r
+  never removed. Such design ensures sytem function well during none console\r
   device situation.\r
 \r
 Copyright (c) 2006 - 2008 Intel Corporation. <BR>\r
@@ -337,7 +337,7 @@ EFI_DRIVER_BINDING_PROTOCOL           gConSplitterAbsolutePointerDriverBinding =
 \r
   Installs driver module protocols and. Creates virtual device handles for ConIn,\r
   ConOut, and StdErr. Installs Simple Text In protocol, Simple Text In Ex protocol,\r
-  Simple Pointer protocol, Absolute Pointer protocol on those virtual handlers. \r
+  Simple Pointer protocol, Absolute Pointer protocol on those virtual handlers.\r
   Installs Graphics Output protocol and/or UGA Draw protocol if needed.\r
 \r
   @param[in] ImageHandle    The firmware allocated handle for the EFI image.\r
@@ -469,7 +469,7 @@ ConSplitterDriverEntry(
   if (!EFI_ERROR (Status)) {\r
     if (!FeaturePcdGet (PcdConOutGopSupport)) {\r
       //\r
-      // If Graphics Outpurt protocol not supported, UGA Draw protocol is installed \r
+      // If Graphics Outpurt protocol not supported, UGA Draw protocol is installed\r
       // on the virtual handle.\r
       //\r
       Status = gBS->InstallMultipleProtocolInterfaces (\r
@@ -565,7 +565,7 @@ ConSplitterTextInConstructor (
   EFI_STATUS  Status;\r
 \r
   //\r
-  // Allocate buffer for Simple Text Input device  \r
+  // Allocate buffer for Simple Text Input device\r
   //\r
   Status = ConSplitterGrowBuffer (\r
             sizeof (EFI_SIMPLE_TEXT_INPUT_PROTOCOL *),\r
@@ -587,7 +587,7 @@ ConSplitterTextInConstructor (
                   );\r
   ASSERT_EFI_ERROR (Status);\r
   //\r
-  // Create Event to wait for a key \r
+  // Create Event to wait for a key\r
   //\r
   Status = gBS->CreateEvent (\r
                   EVT_NOTIFY_WAIT,\r
@@ -599,7 +599,7 @@ ConSplitterTextInConstructor (
   ASSERT_EFI_ERROR (Status);\r
 \r
   //\r
-  // Allocate buffer for Simple Text Input Ex device  \r
+  // Allocate buffer for Simple Text Input Ex device\r
   //\r
   Status = ConSplitterGrowBuffer (\r
              sizeof (EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *),\r
@@ -625,7 +625,7 @@ ConSplitterTextInConstructor (
 \r
   ConInPrivate->AbsolutePointer.Mode = &ConInPrivate->AbsolutePointerMode;\r
   //\r
-  // Allocate buffer for Absolute Pointer device  \r
+  // Allocate buffer for Absolute Pointer device\r
   //\r
   Status = ConSplitterGrowBuffer (\r
             sizeof (EFI_ABSOLUTE_POINTER_PROTOCOL *),\r
@@ -649,7 +649,7 @@ ConSplitterTextInConstructor (
 \r
   ConInPrivate->SimplePointer.Mode = &ConInPrivate->SimplePointerMode;\r
   //\r
-  // Allocate buffer for Simple Pointer device  \r
+  // Allocate buffer for Simple Pointer device\r
   //\r
   Status = ConSplitterGrowBuffer (\r
             sizeof (EFI_SIMPLE_POINTER_PROTOCOL *),\r
@@ -712,7 +712,7 @@ ConSplitterTextOutConstructor (
   //\r
   ConOutPrivate->TextOutMode.Mode = 0xFF;\r
   //\r
-  // Allocate buffer for Console Out device  \r
+  // Allocate buffer for Console Out device\r
   //\r
   Status = ConSplitterGrowBuffer (\r
             sizeof (TEXT_OUT_AND_GOP_DATA),\r
@@ -793,7 +793,7 @@ ConSplitterTextOutConstructor (
 \r
 \r
 /**\r
-  Test to see if the specified protocol could be supported on the specified device. \r
+  Test to see if the specified protocol could be supported on the specified device.\r
 \r
   @param  This                Driver Binding protocol pointer.\r
   @param  ControllerHandle    Handle of device to test.\r
@@ -819,7 +819,7 @@ ConSplitterSupported (
   //\r
   if (ControllerHandle == mConIn.VirtualHandle  ||\r
       ControllerHandle == mConOut.VirtualHandle ||\r
-      ControllerHandle == mStdErr.VirtualHandle \r
+      ControllerHandle == mStdErr.VirtualHandle\r
       ) {\r
     return EFI_UNSUPPORTED;\r
   }\r
@@ -851,7 +851,7 @@ ConSplitterSupported (
 }\r
 \r
 /**\r
-  Test to see if Console In Device could be supported on the Controller. \r
+  Test to see if Console In Device could be supported on the Controller.\r
 \r
   @param  This                Driver Binding protocol instance pointer.\r
   @param  ControllerHandle    Handle of device to test.\r
@@ -878,7 +878,7 @@ ConSplitterConInDriverBindingSupported (
 }\r
 \r
 /**\r
-  Test to see if Simple Pointer protocol could be supported on the Controller. \r
+  Test to see if Simple Pointer protocol could be supported on the Controller.\r
 \r
   @param  This                Driver Binding protocol instance pointer.\r
   @param  ControllerHandle    Handle of device to test.\r
@@ -905,7 +905,7 @@ ConSplitterSimplePointerDriverBindingSupported (
 }\r
 \r
 /**\r
-  Test to see if Absolute Pointer protocol could be supported on the Controller. \r
+  Test to see if Absolute Pointer protocol could be supported on the Controller.\r
 \r
   @param  This                Driver Binding protocol instance pointer.\r
   @param  ControllerHandle    Handle of device to test.\r
@@ -933,7 +933,7 @@ ConSplitterAbsolutePointerDriverBindingSupported (
 \r
 \r
 /**\r
-  Test to see if Console Out Device could be supported on the Controller. \r
+  Test to see if Console Out Device could be supported on the Controller.\r
 \r
   @param  This                Driver Binding protocol instance pointer.\r
   @param  ControllerHandle    Handle of device to test.\r
@@ -960,7 +960,7 @@ ConSplitterConOutDriverBindingSupported (
 }\r
 \r
 /**\r
-  Test to see if Standard Error Device could be supported on the Controller. \r
+  Test to see if Standard Error Device could be supported on the Controller.\r
 \r
   @param  This                Driver Binding protocol instance pointer.\r
   @param  ControllerHandle    Handle of device to test.\r
@@ -988,9 +988,9 @@ ConSplitterStdErrDriverBindingSupported (
 \r
 \r
 /**\r
-  Start ConSplitter on devcie handle by opening Console Device Guid on device handle \r
+  Start ConSplitter on devcie handle by opening Console Device Guid on device handle\r
   and the console virtual handle. And Get the console interface on controller handle.\r
-  \r
+\r
   @param  This                      Driver Binding protocol instance pointer.\r
   @param  ControllerHandle          Handle of device.\r
   @param  ConSplitterVirtualHandle  Console virtual Handle.\r
@@ -1031,7 +1031,7 @@ ConSplitterStart (
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
\r
+\r
   //\r
   // Create virtual handle and open DeviceGuid on the virtul handle.\r
   //\r
@@ -1089,8 +1089,8 @@ Err:
 \r
 \r
 /**\r
-  Start Console In Consplitter on device handle. \r
-  \r
+  Start Console In Consplitter on device handle.\r
+\r
   @param  This                 Driver Binding protocol instance pointer.\r
   @param  ControllerHandle     Handle of device to bind driver to.\r
   @param  RemainingDevicePath  Optional parameter use to pick a specific child\r
@@ -1157,8 +1157,8 @@ ConSplitterConInDriverBindingStart (
 \r
 \r
 /**\r
-  Start Simple Pointer Consplitter on device handle. \r
-  \r
+  Start Simple Pointer Consplitter on device handle.\r
+\r
   @param  This                 Driver Binding protocol instance pointer.\r
   @param  ControllerHandle     Handle of device to bind driver to.\r
   @param  RemainingDevicePath  Optional parameter use to pick a specific child\r
@@ -1203,8 +1203,8 @@ ConSplitterSimplePointerDriverBindingStart (
 \r
 \r
 /**\r
-  Start Absolute Pointer Consplitter on device handle. \r
-  \r
+  Start Absolute Pointer Consplitter on device handle.\r
+\r
   @param  This                 Driver Binding protocol instance pointer.\r
   @param  ControllerHandle     Handle of device to bind driver to.\r
   @param  RemainingDevicePath  Optional parameter use to pick a specific child\r
@@ -1250,8 +1250,8 @@ ConSplitterAbsolutePointerDriverBindingStart (
 \r
 \r
 /**\r
-  Start Console Out Consplitter on device handle. \r
-  \r
+  Start Console Out Consplitter on device handle.\r
+\r
   @param  This                 Driver Binding protocol instance pointer.\r
   @param  ControllerHandle     Handle of device to bind driver to.\r
   @param  RemainingDevicePath  Optional parameter use to pick a specific child\r
@@ -1343,10 +1343,10 @@ ConSplitterConOutDriverBindingStart (
         return Status;\r
       }\r
       ASSERT ( SizeOfInfo <= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION));\r
-        \r
+\r
       mConOut.UgaHorizontalResolution = Info->HorizontalResolution;\r
       mConOut.UgaVerticalResolution   = Info->VerticalResolution;\r
-      mConOut.UgaColorDepth           = 32;        \r
+      mConOut.UgaColorDepth           = 32;\r
       mConOut.UgaRefreshRate          = 60;\r
 \r
       FreePool (Info);\r
@@ -1367,8 +1367,8 @@ ConSplitterConOutDriverBindingStart (
 \r
 \r
 /**\r
-  Start Standard Error Consplitter on device handle. \r
-  \r
+  Start Standard Error Consplitter on device handle.\r
+\r
   @param  This                 Driver Binding protocol instance pointer.\r
   @param  ControllerHandle     Handle of device to bind driver to.\r
   @param  RemainingDevicePath  Optional parameter use to pick a specific child\r
@@ -1440,9 +1440,9 @@ ConSplitterStdErrDriverBindingStart (
 \r
 \r
 /**\r
-  Stop ConSplitter on device handle by closing Console Device Guid on device handle \r
+  Stop ConSplitter on device handle by closing Console Device Guid on device handle\r
   and the console virtual handle.\r
-  \r
+\r
   @param  This                      Protocol instance pointer.\r
   @param  ControllerHandle          Handle of device.\r
   @param  ConSplitterVirtualHandle  Console virtual Handle.\r
@@ -1541,7 +1541,7 @@ ConSplitterConInDriverBindingStop (
     //\r
     // If Simple Text Input Ex protocol exists,\r
     // remove device from Text Input Ex devices list.\r
-    //  \r
+    //\r
     Status = ConSplitterTextInExDeleteDevice (&mConIn, TextInEx);\r
     if (EFI_ERROR (Status)) {\r
       return Status;\r
@@ -1565,7 +1565,7 @@ ConSplitterConInDriverBindingStop (
 \r
   //\r
   // Remove device from Text Input devices list.\r
-  // \r
+  //\r
   return ConSplitterTextInDeleteDevice (&mConIn, TextIn);\r
 }\r
 \r
@@ -1825,7 +1825,7 @@ ConSplitterGrowBuffer (
   //\r
   *Count += CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT;\r
   Ptr = ReallocatePool (\r
-          SizeOfCount * ((*Count) - CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT), \r
+          SizeOfCount * ((*Count) - CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT),\r
           SizeOfCount * (*Count),\r
           *Buffer\r
           );\r
@@ -2237,7 +2237,7 @@ ConSplitterGrowMapTable (
 \r
   @param  Private               Text Out Splitter pointer\r
   @param  TextOut               Simple Text Output protocol pointer.\r
-  \r
+\r
   @retval EFI_SUCCESS           Device added successfully.\r
   @retval EFI_OUT_OF_RESOURCES  Could not grow the buffer size.\r
 \r
@@ -2387,7 +2387,7 @@ ConSplitterGetIntersection (
 \r
   @param  Private               Text Out Splitter pointer.\r
   @param  TextOut               Simple Text Output protocol pointer.\r
-  \r
+\r
 **/\r
 VOID\r
 ConSplitterSyncOutputMode (\r
@@ -2741,7 +2741,7 @@ ConSplitterAddGraphicsOutputMode (
           if ((Info->HorizontalResolution == Mode->HorizontalResolution) &&\r
               (Info->VerticalResolution == Mode->VerticalResolution)) {\r
             //\r
-            // If GOP device supports one mode in current mode buffer, \r
+            // If GOP device supports one mode in current mode buffer,\r
             // it will be added into matched mode buffer\r
             //\r
             Match = TRUE;\r
@@ -2753,7 +2753,7 @@ ConSplitterAddGraphicsOutputMode (
 \r
         if (Match) {\r
           AlreadyExist = FALSE;\r
-          \r
+\r
           //\r
           // Check if GOP mode has been in the mode buffer, ModeBuffer = MatchedMode at begin.\r
           //\r
@@ -3101,7 +3101,7 @@ ConSplitterTextOutAddDevice (
   if (FeaturePcdGet (PcdConOutUgaSupport)) {\r
     UgaHorizontalResolution = 800;\r
     UgaVerticalResolution   = 600;\r
-    UgaColorDepth           = 32;        \r
+    UgaColorDepth           = 32;\r
     UgaRefreshRate          = 60;\r
 \r
     Status = EFI_DEVICE_ERROR;\r
@@ -3119,7 +3119,7 @@ ConSplitterTextOutAddDevice (
       UgaVerticalResolution   = Info->VerticalResolution;\r
 \r
       FreePool (Info);\r
-    \r
+\r
     } else if (UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport)) {\r
       Status = UgaDraw->GetMode (\r
                     UgaDraw,\r
@@ -3129,7 +3129,7 @@ ConSplitterTextOutAddDevice (
                     &UgaRefreshRate\r
                     );\r
     }\r
-    \r
+\r
     //\r
     //  Set UGA Draw mode,\r
     //  if GetMode is failed, set to 800x600 mode\r
@@ -3469,7 +3469,7 @@ ConSpliterConsoleControlLockStdInEvent (
 \r
 \r
 /**\r
-  If Password is NULL or the Password is too big, then return an error. If the \r
+  If Password is NULL or the Password is too big, then return an error. If the\r
   Password is valid, then store the password, lock StdIn and arm the periodic timer.\r
 \r
   @param  This                     Console Control protocol pointer.\r
@@ -4495,6 +4495,8 @@ ConSplitterTextOutOutputString (
     TargetString = WString;\r
   } else {\r
     TargetString = AllocatePool (sizeof (CHAR16) * (StrLen (WString) + BackSpaceCount + 1));\r
+    ASSERT (TargetString != NULL);\r
+\r
     StrCpy (TargetString, WString);\r
   }\r
   //\r