public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Gao, Liming" <liming.gao@intel.com>
To: "Zeng, Star" <star.zeng@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Subject: Re: [PATCH] MdeModulePkg DxeCore: Only free ScratchBuffer when it is not NULL
Date: Fri, 23 Jun 2017 10:40:55 +0000	[thread overview]
Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14D74E08A@shsmsx102.ccr.corp.intel.com> (raw)
In-Reply-To: <1498211124-157132-1-git-send-email-star.zeng@intel.com>

Good catch. Reviewed-by: Liming Gao <liming.gao@intel.com>

>-----Original Message-----
>From: Zeng, Star
>Sent: Friday, June 23, 2017 5:45 PM
>To: edk2-devel@lists.01.org
>Cc: Zeng, Star <star.zeng@intel.com>; Gao, Liming <liming.gao@intel.com>
>Subject: [PATCH] MdeModulePkg DxeCore: Only free ScratchBuffer when it is
>not NULL
>
>There is a case that ExtractGuidedSectionGetInfo return 0 for
>ScratchBufferSize and ScratchBuffer will be NULL, after AllocatePool
>fails to allocate buffer for AllocatedOutputBuffer, the code will
>call FreePool (ScratchBuffer), but ScratchBuffer == NULL.
>
>This patch is to only free ScratchBuffer when it is not NULL.
>
>Cc: Liming Gao <liming.gao@intel.com>
>Contributed-under: TianoCore Contribution Agreement 1.0
>Signed-off-by: Star Zeng <star.zeng@intel.com>
>---
> MdeModulePkg/Core/Dxe/SectionExtraction/CoreSectionExtraction.c | 6
>++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
>diff --git
>a/MdeModulePkg/Core/Dxe/SectionExtraction/CoreSectionExtraction.c
>b/MdeModulePkg/Core/Dxe/SectionExtraction/CoreSectionExtraction.c
>index 6622eeeaf161..9561ae176655 100644
>--- a/MdeModulePkg/Core/Dxe/SectionExtraction/CoreSectionExtraction.c
>+++ b/MdeModulePkg/Core/Dxe/SectionExtraction/CoreSectionExtraction.c
>@@ -27,7 +27,7 @@
>   3) A support protocol is not found, and the data is not available to be read
>      without it.  This results in EFI_PROTOCOL_ERROR.
>
>-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
>+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
> This program and the accompanying materials
> are licensed and made available under the terms and conditions of the BSD
>License
> which accompanies this distribution.  The full text of the license may be found
>at
>@@ -1551,7 +1551,9 @@ CustomGuidedSectionExtract (
>     //
>     AllocatedOutputBuffer = AllocatePool (OutputBufferSize);
>     if (AllocatedOutputBuffer == NULL) {
>-      FreePool (ScratchBuffer);
>+      if (ScratchBuffer != NULL) {
>+        FreePool (ScratchBuffer);
>+      }
>       return EFI_OUT_OF_RESOURCES;
>     }
>     *OutputBuffer = AllocatedOutputBuffer;
>--
>2.7.0.windows.1



      reply	other threads:[~2017-06-23 10:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-23  9:45 [PATCH] MdeModulePkg DxeCore: Only free ScratchBuffer when it is not NULL Star Zeng
2017-06-23 10:40 ` Gao, Liming [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A89E2EF3DFEDB4C8BFDE51014F606A14D74E08A@shsmsx102.ccr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox