]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.c
1. Fixed one bug in ConPlatform.c, add NULL judgment.
[mirror_edk2.git] / MdeModulePkg / Universal / Console / ConPlatformDxe / ConPlatform.c
index 61ed14b4e7d2e8fe07ed3bd6540e023f5f8113ad..e4f7e18e99cdb2398619065ba7845e4e6bbedee5 100644 (file)
@@ -41,9 +41,9 @@ EFI_DRIVER_BINDING_PROTOCOL gConPlatformTextOutDriverBinding = {
 /**\r
   The user Entry Point for module ConPlatform. The user code starts with this function.\r
 \r
-  @param[in] ImageHandle    The firmware allocated handle for the EFI image.  \r
+  @param[in] ImageHandle    The firmware allocated handle for the EFI image.\r
   @param[in] SystemTable    A pointer to the EFI System Table.\r
-  \r
+\r
   @retval EFI_SUCCESS       The entry point is executed successfully.\r
   @retval other             Some error occurs when executing this entry point.\r
 \r
@@ -739,8 +739,7 @@ Returns:
 --*/\r
 {\r
   EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
-  EFI_DEVICE_PATH_PROTOCOL  *TempDevicePath1;\r
-  EFI_DEVICE_PATH_PROTOCOL  *TempDevicePath2;\r
+  EFI_DEVICE_PATH_PROTOCOL  *TempDevicePath;\r
   EFI_DEVICE_PATH_PROTOCOL  *DevicePathInst;\r
   UINTN                     Size;\r
 \r
@@ -753,7 +752,7 @@ Returns:
   //\r
   // if performing Delete operation, the NewDevicePath must not be NULL.\r
   //\r
-  TempDevicePath1 = NULL;\r
+  TempDevicePath  = NULL;\r
 \r
   DevicePath      = Multi;\r
   DevicePathInst  = GetNextDevicePathInstance (&DevicePath, &Size);\r
@@ -769,14 +768,10 @@ Returns:
       }\r
     } else {\r
       if (Delete) {\r
-        TempDevicePath2 = AppendDevicePathInstance (\r
-                            TempDevicePath1,\r
+        TempDevicePath = AppendDevicePathInstance (\r
+                            NULL,\r
                             DevicePathInst\r
                             );\r
-        if (TempDevicePath1 != NULL) {\r
-          FreePool (TempDevicePath1);\r
-        }\r
-        TempDevicePath1 = TempDevicePath2;\r
       }\r
     }\r
 \r
@@ -785,7 +780,7 @@ Returns:
   }\r
 \r
   if (Delete) {\r
-    *NewDevicePath = TempDevicePath1;\r
+    *NewDevicePath = TempDevicePath;\r
     return EFI_SUCCESS;\r
   }\r
 \r
@@ -878,15 +873,17 @@ Returns:
     return Status;\r
   }\r
 \r
-  Status = gRT->SetVariable (\r
-                  VariableName,\r
-                  &gEfiGlobalVariableGuid,\r
-                  EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
-                  GetDevicePathSize (NewVariableDevicePath),\r
-                  NewVariableDevicePath\r
-                  );\r
+  if (NewVariableDevicePath != NULL) {\r
+    Status = gRT->SetVariable (\r
+                    VariableName,\r
+                    &gEfiGlobalVariableGuid,\r
+                    EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
+                    GetDevicePathSize (NewVariableDevicePath),\r
+                    NewVariableDevicePath\r
+                    );\r
 \r
-  FreePool (NewVariableDevicePath);\r
+    FreePool (NewVariableDevicePath);\r
+  }\r
 \r
   return Status;\r
 }\r