diff mbox

[edk2,2/2] ArmPlatformPkg: fix two instances of FreePool () on NULL value

Message ID 1427472286-20051-2-git-send-email-ard.biesheuvel@linaro.org
State New
Headers show

Commit Message

Ard Biesheuvel March 27, 2015, 4:04 p.m. UTC
This is a copy/paste of the exact same code in both cases: Buffer
should only be freed on the success path, otherwise it will be
NULL

Contributed-under: TianoCore Contribution Agreement 1.0
Reviewed-by: Ronald Cron <Ronald.Cron@arm.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 ArmPlatformPkg/Bds/Bds.c                                      | 2 +-
 ArmPlatformPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
diff mbox

Patch

diff --git a/ArmPlatformPkg/Bds/Bds.c b/ArmPlatformPkg/Bds/Bds.c
index 971ab07524d7..6a12717a1c12 100644
--- a/ArmPlatformPkg/Bds/Bds.c
+++ b/ArmPlatformPkg/Bds/Bds.c
@@ -155,8 +155,8 @@  InitializeConsolePipe (
       *Handle = Buffer[0];
       Status = gBS->HandleProtocol (*Handle, Protocol, Interface);
       ASSERT_EFI_ERROR(Status);
+      FreePool (Buffer);
     }
-    FreePool (Buffer);
   } else {
     Status = EFI_SUCCESS;
   }
diff --git a/ArmPlatformPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c b/ArmPlatformPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c
index c07fc0f607d7..c010e8a0ce02 100644
--- a/ArmPlatformPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c
+++ b/ArmPlatformPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c
@@ -179,8 +179,8 @@  InitializeConsolePipe (
       *Handle = Buffer[0];
       Status = gBS->HandleProtocol (*Handle, Protocol, Interface);
       ASSERT_EFI_ERROR (Status);
+      FreePool (Buffer);
     }
-    FreePool (Buffer);
   } else {
     Status = EFI_SUCCESS;
   }