diff mbox

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

Message ID 1427402908-15652-1-git-send-email-ard.biesheuvel@linaro.org
State New
Headers show

Commit Message

Ard Biesheuvel March 26, 2015, 8:48 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

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(-)

Comments

Ard Biesheuvel March 26, 2015, 8:49 p.m. UTC | #1
please ignore the 1/2 in the subject, it's just this single patch

On 26 March 2015 at 21:48, Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
> 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
>
> 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 --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;
>    }
> --
> 1.8.3.2
>

------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
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;
   }