[edk2] [Patch 1/2] NetworkPkg/HttpBootDxe: Add check to avoid use NULL pointer

Jiaxin Wu posted 2 patches 7 years, 1 month ago
[edk2] [Patch 1/2] NetworkPkg/HttpBootDxe: Add check to avoid use NULL pointer
Posted by Jiaxin Wu 7 years, 1 month ago
Cc: Wu Hao A <hao.a.wu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
---
 NetworkPkg/HttpBootDxe/HttpBootDxe.c | 50 +++++++++++++++++++-----------------
 1 file changed, 27 insertions(+), 23 deletions(-)

diff --git a/NetworkPkg/HttpBootDxe/HttpBootDxe.c b/NetworkPkg/HttpBootDxe/HttpBootDxe.c
index b1f9042..8a61f51 100644
--- a/NetworkPkg/HttpBootDxe/HttpBootDxe.c
+++ b/NetworkPkg/HttpBootDxe/HttpBootDxe.c
@@ -613,23 +613,25 @@ HttpBootIp4DxeDriverBindingStart (
   }
   
   return EFI_SUCCESS;
     
 ON_ERROR:
-  if (FirstStart) {
-    gBS->UninstallProtocolInterface (
-           ControllerHandle,
-           &gEfiCallerIdGuid,
-           &Private->Id
-           );
-  }
-  
-  HttpBootDestroyIp4Children (This, Private);
-  HttpBootConfigFormUnload (Private);
+  if (Private != NULL) {
+    if (FirstStart) {
+      gBS->UninstallProtocolInterface (
+             ControllerHandle,
+             &gEfiCallerIdGuid,
+             &Private->Id
+             );
+    }
+    
+    HttpBootDestroyIp4Children (This, Private);
+    HttpBootConfigFormUnload (Private);
 
-  if (FirstStart && Private != NULL) {
-    FreePool (Private);
+    if (FirstStart) {
+      FreePool (Private);
+    }
   }
 
   return Status;
 }
 
@@ -1142,23 +1144,25 @@ HttpBootIp6DxeDriverBindingStart (
   }
 
   return EFI_SUCCESS;
    
 ON_ERROR:
-  if (FirstStart) {
-    gBS->UninstallProtocolInterface (
-           ControllerHandle,
-           &gEfiCallerIdGuid,
-           &Private->Id
-           );
-  }
+  if (Private != NULL) {
+    if (FirstStart) {
+      gBS->UninstallProtocolInterface (
+             ControllerHandle,
+             &gEfiCallerIdGuid,
+             &Private->Id
+             );
+    }
 
-  HttpBootDestroyIp6Children(This, Private);
-  HttpBootConfigFormUnload (Private);
+    HttpBootDestroyIp6Children(This, Private);
+    HttpBootConfigFormUnload (Private);
 
-  if (FirstStart && Private != NULL) {
-    FreePool (Private);
+    if (FirstStart) {
+      FreePool (Private);
+    }
   }
 
   return Status;
 }
 
-- 
1.9.5.msysgit.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel