]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Correct DriverSample to produce the ConfigAccess protocol
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 18 May 2009 05:03:45 +0000 (05:03 +0000)
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 18 May 2009 05:03:45 +0000 (05:03 +0000)
And fix the bug in HiiDataBase to incorrectly free pool.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8321 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c
MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c

index 39e72909daed87a9dfe183f448bf8ce562d66484..784cd28d7a795ea1f58d6f4a5bf6059de9567dd3 100644 (file)
@@ -362,13 +362,16 @@ ExtractConfig (
   // Try to get the current setting from variable.\r
   //\r
   BufferSize = sizeof (DRIVER_SAMPLE_CONFIGURATION);\r
-  gRT->GetVariable (\r
-        VariableName,\r
-        &mFormSetGuid,\r
-        NULL,\r
-        &BufferSize,\r
-        &PrivateData->Configuration\r
-        );\r
+  Status = gRT->GetVariable (\r
+            VariableName,\r
+            &mFormSetGuid,\r
+            NULL,\r
+            &BufferSize,\r
+            &PrivateData->Configuration\r
+            );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
   \r
   if (Request == NULL) {\r
     //\r
@@ -476,13 +479,16 @@ RouteConfig (
   // Get Buffer Storage data from EFI variable\r
   //\r
   BufferSize = sizeof (DRIVER_SAMPLE_CONFIGURATION);\r
-  gRT->GetVariable (\r
-        VariableName,\r
-        &mFormSetGuid,\r
-        NULL,\r
-        &BufferSize,\r
-        &PrivateData->Configuration\r
-        );\r
+  Status = gRT->GetVariable (\r
+            VariableName,\r
+            &mFormSetGuid,\r
+            NULL,\r
+            &BufferSize,\r
+            &PrivateData->Configuration\r
+            );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
 \r
   //\r
   // Convert <ConfigResp> to buffer data by helper function ConfigToBlock()\r
@@ -968,6 +974,17 @@ DriverSampleInit (
   BufferSize = sizeof (DRIVER_SAMPLE_CONFIGURATION);\r
   Status = gRT->GetVariable (VariableName, &mFormSetGuid, NULL, &BufferSize, Configuration);\r
   if (EFI_ERROR (Status)) {\r
+    //\r
+    // Store zero data Buffer Storage to EFI variable\r
+    //\r
+    Status = gRT->SetVariable(\r
+                    VariableName,\r
+                    &mFormSetGuid,\r
+                    EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,\r
+                    sizeof (DRIVER_SAMPLE_CONFIGURATION),\r
+                    Configuration\r
+                    );\r
+    ASSERT (Status == EFI_SUCCESS);\r
     //\r
     // EFI variable for NV config doesn't exit, we should build this variable\r
     // based on default values stored in IFR\r
index fe035969717bc10f337b873f180a2d3aa2ab79d1..2f5118e51268b58c661aa1454045429c9ad39027 100644 (file)
@@ -873,9 +873,9 @@ ParseIfrData (
       LengthString = StrLen (GuidStr);\r
       LengthString = LengthString + StrLen (NameStr) + 1;\r
       TempStr = AllocateZeroPool (LengthString * sizeof (CHAR16));\r
-      FreePool (GuidStr);\r
-      FreePool (NameStr);\r
     if (TempStr == NULL) {\r
+        FreePool (GuidStr);\r
+        FreePool (NameStr);\r
         FreePool (VarStoreName);\r
         Status = EFI_OUT_OF_RESOURCES;\r
         goto Done;\r
@@ -899,6 +899,8 @@ ParseIfrData (
       //\r
       // Free alllocated temp string.\r
       //\r
+      FreePool (GuidStr);\r
+      FreePool (NameStr);\r
       FreePool (TempStr);\r
       break;\r
 \r