public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Yao, Jiewen" <jiewen.yao@intel.com>
To: "Zeng, Star" <star.zeng@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Subject: Re: [PATCH] MdeModulePkg SmiHandlerProfile: Fix memory leak in DumpSmiChildContext
Date: Thu, 11 May 2017 13:42:43 +0000	[thread overview]
Message-ID: <74D8A39837DF1E4DA445A8C0B3885C503A94505F@SHSMSX104.ccr.corp.intel.com> (raw)
In-Reply-To: <1494496607-99080-1-git-send-email-star.zeng@intel.com>

Reviewed-by: jiewen.yao@intel.com

> -----Original Message-----
> From: Zeng, Star
> Sent: Thursday, May 11, 2017 5:57 PM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star <star.zeng@intel.com>; Yao, Jiewen <jiewen.yao@intel.com>
> Subject: [PATCH] MdeModulePkg SmiHandlerProfile: Fix memory leak in
> DumpSmiChildContext
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=530
> 
> In DumpSmiChildContext() of SmiHandlerProfile.c and
> SmiHandlerProfileInfo.c, the return buffer from
> ConvertDevicePathToText() should be freed after used.
> 
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Star Zeng <star.zeng@intel.com>
> ---
>  .../Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo.c     | 8
> +++++++-
>  MdeModulePkg/Core/PiSmmCore/SmiHandlerProfile.c                   | 8
> +++++++-
>  2 files changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git
> a/MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo.c
> b/MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo.c
> index 84a1c8ee53b6..2419cd2959a9 100644
> ---
> a/MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo.c
> +++
> b/MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo.c
> @@ -535,6 +535,8 @@ DumpSmiChildContext (
>    IN UINTN      ContextSize
>    )
>  {
> +  CHAR16        *Str;
> +
>    if (CompareGuid (HandlerType, &gEfiSmmSwDispatch2ProtocolGuid)) {
>      Print(L" SwSmi=\"0x%x\"", ((EFI_SMM_SW_REGISTER_CONTEXT
> *)Context)->SwSmiInputValue);
>    } else if (CompareGuid (HandlerType, &gEfiSmmSxDispatch2ProtocolGuid)) {
> @@ -555,7 +557,11 @@ DumpSmiChildContext (
>      Print(L" IoTrapType=\"%a\"",
> IoTrapTypeToString(((EFI_SMM_IO_TRAP_REGISTER_CONTEXT
> *)Context)->Type));
>    } else if (CompareGuid (HandlerType, &gEfiSmmUsbDispatch2ProtocolGuid)) {
>      Print(L" UsbType=\"0x%x\"",
> UsbTypeToString(((SMI_HANDLER_PROFILE_USB_REGISTER_CONTEXT
> *)Context)->Type));
> -    Print(L" UsbDevicePath=\"%s\"",
> ConvertDevicePathToText((EFI_DEVICE_PATH_PROTOCOL
> *)(((SMI_HANDLER_PROFILE_USB_REGISTER_CONTEXT *)Context) + 1), TRUE,
> TRUE));
> +    Str = ConvertDevicePathToText((EFI_DEVICE_PATH_PROTOCOL
> *)(((SMI_HANDLER_PROFILE_USB_REGISTER_CONTEXT *)Context) + 1), TRUE,
> TRUE);
> +    Print(L" UsbDevicePath=\"%s\"", Str);
> +    if (Str != NULL) {
> +      FreePool (Str);
> +    }
>    } else {
>      Print(L" Context=\"");
>      InternalDumpData (Context, ContextSize);
> diff --git a/MdeModulePkg/Core/PiSmmCore/SmiHandlerProfile.c
> b/MdeModulePkg/Core/PiSmmCore/SmiHandlerProfile.c
> index ad3b54ace428..63dcf6e3a1e7 100644
> --- a/MdeModulePkg/Core/PiSmmCore/SmiHandlerProfile.c
> +++ b/MdeModulePkg/Core/PiSmmCore/SmiHandlerProfile.c
> @@ -356,6 +356,8 @@ DumpSmiChildContext (
>    IN UINTN      ContextSize
>    )
>  {
> +  CHAR16        *Str;
> +
>    if (CompareGuid (HandlerType, &gEfiSmmSwDispatch2ProtocolGuid)) {
>      DEBUG ((DEBUG_INFO, "  SwSmi - 0x%x\n",
> ((EFI_SMM_SW_REGISTER_CONTEXT *)Context)->SwSmiInputValue));
>    } else if (CompareGuid (HandlerType, &gEfiSmmSxDispatch2ProtocolGuid)) {
> @@ -376,7 +378,11 @@ DumpSmiChildContext (
>      DEBUG ((DEBUG_INFO, "  IoTrapType - 0x%x\n",
> ((EFI_SMM_IO_TRAP_REGISTER_CONTEXT *)Context)->Type));
>    } else if (CompareGuid (HandlerType, &gEfiSmmUsbDispatch2ProtocolGuid)) {
>      DEBUG ((DEBUG_INFO, "  UsbType - 0x%x\n",
> ((SMI_HANDLER_PROFILE_USB_REGISTER_CONTEXT *)Context)->Type));
> -    DEBUG ((DEBUG_INFO, "  UsbDevicePath - %s\n",
> ConvertDevicePathToText((EFI_DEVICE_PATH_PROTOCOL
> *)(((SMI_HANDLER_PROFILE_USB_REGISTER_CONTEXT *)Context) + 1), TRUE,
> TRUE)));
> +    Str = ConvertDevicePathToText((EFI_DEVICE_PATH_PROTOCOL
> *)(((SMI_HANDLER_PROFILE_USB_REGISTER_CONTEXT *)Context) + 1), TRUE,
> TRUE);
> +    DEBUG ((DEBUG_INFO, "  UsbDevicePath - %s\n", Str));
> +    if (Str != NULL) {
> +      FreePool (Str);
> +    }
>    } else {
>      DEBUG ((DEBUG_INFO, "  Context - "));
>      InternalDumpData (Context, ContextSize);
> --
> 2.7.0.windows.1



      reply	other threads:[~2017-05-11 13:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-11  9:56 [PATCH] MdeModulePkg SmiHandlerProfile: Fix memory leak in DumpSmiChildContext Star Zeng
2017-05-11 13:42 ` Yao, Jiewen [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=74D8A39837DF1E4DA445A8C0B3885C503A94505F@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