public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch] MdeModulePkg HiiDataBase: Fix the potential NULL pointer access
@ 2017-12-28  4:54 Liming Gao
  2017-12-28  5:01 ` Zeng, Star
  0 siblings, 1 reply; 2+ messages in thread
From: Liming Gao @ 2017-12-28  4:54 UTC (permalink / raw)
  To: edk2-devel; +Cc: Star Zeng

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
---
 MdeModulePkg/Universal/HiiDatabaseDxe/Database.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c b/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c
index 4a2dc8d030..e8f4564e64 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c
@@ -721,9 +721,14 @@ FindQuestionDefaultSetting (
       VariableStorage = NULL;
     }
     Entry = AllocatePool (sizeof (VARSTORAGE_DEFAULT_DATA));
-    Entry->DefaultId = DefaultId;
-    Entry->VariableStorage = VariableStorage;
-    InsertTailList (&gVarStorageList, &Entry->Entry);
+    if (Entry != NULL) {
+      Entry->DefaultId = DefaultId;
+      Entry->VariableStorage = VariableStorage;
+      InsertTailList (&gVarStorageList, &Entry->Entry);
+    } else if (VariableStorage != NULL) {
+      FreePool (VariableStorage);
+      VariableStorage = NULL;
+    }
   }
   //
   // The matched variable storage is not found.
-- 
2.11.0.windows.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Patch] MdeModulePkg HiiDataBase: Fix the potential NULL pointer access
  2017-12-28  4:54 [Patch] MdeModulePkg HiiDataBase: Fix the potential NULL pointer access Liming Gao
@ 2017-12-28  5:01 ` Zeng, Star
  0 siblings, 0 replies; 2+ messages in thread
From: Zeng, Star @ 2017-12-28  5:01 UTC (permalink / raw)
  To: Gao, Liming, edk2-devel@lists.01.org; +Cc: Zeng, Star

Reviewed-by: Star Zeng <star.zeng@intel.com>

Thanks,
Star
-----Original Message-----
From: Gao, Liming 
Sent: Thursday, December 28, 2017 12:54 PM
To: edk2-devel@lists.01.org
Cc: Zeng, Star <star.zeng@intel.com>
Subject: [Patch] MdeModulePkg HiiDataBase: Fix the potential NULL pointer access

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
---
 MdeModulePkg/Universal/HiiDatabaseDxe/Database.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c b/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c
index 4a2dc8d030..e8f4564e64 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c
@@ -721,9 +721,14 @@ FindQuestionDefaultSetting (
       VariableStorage = NULL;
     }
     Entry = AllocatePool (sizeof (VARSTORAGE_DEFAULT_DATA));
-    Entry->DefaultId = DefaultId;
-    Entry->VariableStorage = VariableStorage;
-    InsertTailList (&gVarStorageList, &Entry->Entry);
+    if (Entry != NULL) {
+      Entry->DefaultId = DefaultId;
+      Entry->VariableStorage = VariableStorage;
+      InsertTailList (&gVarStorageList, &Entry->Entry);
+    } else if (VariableStorage != NULL) {
+      FreePool (VariableStorage);
+      VariableStorage = NULL;
+    }
   }
   //
   // The matched variable storage is not found.
-- 
2.11.0.windows.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-12-28  4:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-28  4:54 [Patch] MdeModulePkg HiiDataBase: Fix the potential NULL pointer access Liming Gao
2017-12-28  5:01 ` Zeng, Star

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox