public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ni, Ruiyu" <ruiyu.ni@intel.com>
To: "Bi, Dandan" <dandan.bi@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Gao, Liming" <liming.gao@intel.com>,
	"Carsey, Jaben" <jaben.carsey@intel.com>
Subject: Re: [patch 1/3] ShellPkg/Dp: make sure memory is freed before exit
Date: Mon, 11 Jun 2018 03:01:12 +0000	[thread overview]
Message-ID: <734D49CCEBEEF84792F5B80ED585239D5BD2DE66@SHSMSX104.ccr.corp.intel.com> (raw)
In-Reply-To: <20180605083243.81276-1-dandan.bi@intel.com>

Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>

Thanks/Ray

> -----Original Message-----
> From: Bi, Dandan
> Sent: Tuesday, June 5, 2018 4:33 PM
> To: edk2-devel@lists.01.org
> Cc: Gao, Liming <liming.gao@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>;
> Carsey, Jaben <jaben.carsey@intel.com>
> Subject: [patch 1/3] ShellPkg/Dp: make sure memory is freed before exit
> 
> Run dp command now:
> Firstly it will get performance records from FPDT and then parse the DP
> command. And if encounter invalid parameters, it will exit directly. Thus the
> performance records got before are invalid. And what's worse is that the
> memory allocated in getting performance records phase is not freed.
> 
> This patch update the code to parse the command firstly and then get the
> performance records. And make sure that all the clean work has been done
> before exiting.
> 
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Jaben Carsey <jaben.carsey@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Dandan Bi <dandan.bi@intel.com>
> ---
>  ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c | 70
> ++++++++++++++-------------
>  1 file changed, 37 insertions(+), 33 deletions(-)
> 
> diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
> b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
> index aa9c2cdf7a8..fe85937f557 100644
> --- a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
> +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
> @@ -390,11 +390,11 @@ BuildCachedGuidHandleTable (
>    }
>    if (HandleBuffer != NULL) {
>      FreePool (HandleBuffer);
>      HandleBuffer = NULL;
>    }
> -  return Status;
> +  return EFI_SUCCESS;
>  }
> 
>  /**
>    Get Measurement form Fpdt records.
> 
> @@ -729,39 +729,10 @@ RunDp (
>    // initialize the shell lib (we must be in non-auto-init...)
>    //
>    Status = ShellInitialize();
>    ASSERT_EFI_ERROR(Status);
> 
> -  //
> -  // DP dump performance data by parsing FPDT table in ACPI table.
> -  // Folloing 3 steps are to get the measurement form the FPDT table.
> -  //
> -
> -  //
> -  //1. Get FPDT from ACPI table.
> -  //
> -  Status = GetBootPerformanceTable ();
> -  if (EFI_ERROR(Status)) {
> -    return Status;
> -  }
> -
> -  //
> -  //2. Cache the ModuleGuid and hanlde mapping table.
> -  //
> -  Status = BuildCachedGuidHandleTable();
> -  if (EFI_ERROR (Status)) {
> -    return Status;
> -  }
> -
> -  //
> -  //3. Build the measurement array form the FPDT records.
> -  //
> -  Status = BuildMeasurementList ();
> -  if (EFI_ERROR(Status)) {
> -    return Status;
> -  }
> -
>    //
>    // Process Command Line arguments
>    //
>    Status = ShellCommandLineParse (ParamList, &ParamPackage, NULL, TRUE);
>    if (EFI_ERROR(Status)) {
> @@ -809,10 +780,42 @@ RunDp (
>  #if PROFILING_IMPLEMENTED
>      ProfileMode = TRUE;
>  #endif  // PROFILING_IMPLEMENTED
>    }
> 
> +  //
> +  // DP dump performance data by parsing FPDT table in ACPI table.
> +  // Folloing 3 steps are to get the measurement form the FPDT table.
> +  //
> +
> +  //
> +  //1. Get FPDT from ACPI table.
> +  //
> +  Status = GetBootPerformanceTable ();
> +  if (EFI_ERROR (Status)) {
> +    ShellStatus = Status;
> +    goto Done;
> +  }
> +
> +  //
> +  //2. Cache the ModuleGuid and hanlde mapping table.
> +  //
> +  Status = BuildCachedGuidHandleTable();  if (EFI_ERROR (Status)) {
> +    ShellStatus = Status;
> +    goto Done;
> +  }
> +
> +  //
> +  //3. Build the measurement array form the FPDT records.
> +  //
> +  Status = BuildMeasurementList ();
> +  if (EFI_ERROR (Status)) {
> +    ShellStatus = SHELL_OUT_OF_RESOURCES;
> +    goto Done;
> +  }
> +
>    //
>    // Initialize the pre-defined cumulative data.
>    //
>    InitCumulativeData ();
> 
> @@ -821,21 +824,22 @@ RunDp (
>    //
>    CustomCumulativeToken = ShellCommandLineGetValue (ParamPackage,
> L"-c");
>    if (CustomCumulativeToken != NULL) {
>      CustomCumulativeData = AllocateZeroPool (sizeof (PERF_CUM_DATA));
>      if (CustomCumulativeData == NULL) {
> -      return SHELL_OUT_OF_RESOURCES;
> +      ShellStatus = SHELL_OUT_OF_RESOURCES;
> +      goto Done;
>      }
>      CustomCumulativeData->MinDur = PERF_MAXDUR;
>      CustomCumulativeData->MaxDur = 0;
>      CustomCumulativeData->Count  = 0;
>      CustomCumulativeData->Duration = 0;
>      NameSize = StrLen (CustomCumulativeToken) + 1;
>      CustomCumulativeData->Name   = AllocateZeroPool (NameSize);
>      if (CustomCumulativeData->Name == NULL) {
> -      FreePool (CustomCumulativeData);
> -      return SHELL_OUT_OF_RESOURCES;
> +      ShellStatus = SHELL_OUT_OF_RESOURCES;
> +      goto Done;
>      }
>      UnicodeStrToAsciiStrS (CustomCumulativeToken, CustomCumulativeData-
> >Name, NameSize);
>    }
> 
>    //
> --
> 2.14.3.windows.1



  parent reply	other threads:[~2018-06-11  3:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-05  8:32 [patch 1/3] ShellPkg/Dp: make sure memory is freed before exit Dandan Bi
2018-06-05  8:32 ` [patch 2/3] ShellPkg/Dp: Initialize summary date when run DP Dandan Bi
2018-06-05  8:32 ` [patch 3/3] ShellPkg/Dp: Make the help info align with code Dandan Bi
2018-06-11  3:10   ` Gao, Liming
2018-06-11  3:01 ` Ni, Ruiyu [this message]
  -- strict thread matches above, loose matches on Subject: below --
2018-05-14  5:46 [patch 1/3] ShellPkg/Dp: make sure memory is freed before exit Dandan Bi

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=734D49CCEBEEF84792F5B80ED585239D5BD2DE66@SHSMSX104.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