From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 2E03B21A134BC for ; Thu, 11 May 2017 06:42:48 -0700 (PDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 May 2017 06:42:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,324,1491289200"; d="scan'208";a="85584318" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga002.jf.intel.com with ESMTP; 11 May 2017 06:42:47 -0700 Received: from fmsmsx115.amr.corp.intel.com (10.18.116.19) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 11 May 2017 06:42:47 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx115.amr.corp.intel.com (10.18.116.19) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 11 May 2017 06:42:47 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.178]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.224]) with mapi id 14.03.0319.002; Thu, 11 May 2017 21:42:43 +0800 From: "Yao, Jiewen" To: "Zeng, Star" , "edk2-devel@lists.01.org" Thread-Topic: [PATCH] MdeModulePkg SmiHandlerProfile: Fix memory leak in DumpSmiChildContext Thread-Index: AQHSyjzt1d5wTJrWtEixnNTF+How3KHvJGig Date: Thu, 11 May 2017 13:42:43 +0000 Message-ID: <74D8A39837DF1E4DA445A8C0B3885C503A94505F@SHSMSX104.ccr.corp.intel.com> References: <1494496607-99080-1-git-send-email-star.zeng@intel.com> In-Reply-To: <1494496607-99080-1-git-send-email-star.zeng@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 10.0.102.7 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] MdeModulePkg SmiHandlerProfile: Fix memory leak in DumpSmiChildContext X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 May 2017 13:42:48 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable 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 ; Yao, Jiewen > Subject: [PATCH] MdeModulePkg SmiHandlerProfile: Fix memory leak in > DumpSmiChildContext >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D530 >=20 > In DumpSmiChildContext() of SmiHandlerProfile.c and > SmiHandlerProfileInfo.c, the return buffer from > ConvertDevicePathToText() should be freed after used. >=20 > Cc: Jiewen Yao > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Star Zeng > --- > .../Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo.c | 8 > +++++++- > MdeModulePkg/Core/PiSmmCore/SmiHandlerProfile.c | 8 > +++++++- > 2 files changed, 14 insertions(+), 2 deletions(-) >=20 > 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=3D\"0x%x\"", ((EFI_SMM_SW_REGISTER_CONTEXT > *)Context)->SwSmiInputValue); > } else if (CompareGuid (HandlerType, &gEfiSmmSxDispatch2ProtocolGuid))= { > @@ -555,7 +557,11 @@ DumpSmiChildContext ( > Print(L" IoTrapType=3D\"%a\"", > IoTrapTypeToString(((EFI_SMM_IO_TRAP_REGISTER_CONTEXT > *)Context)->Type)); > } else if (CompareGuid (HandlerType, &gEfiSmmUsbDispatch2ProtocolGuid)= ) { > Print(L" UsbType=3D\"0x%x\"", > UsbTypeToString(((SMI_HANDLER_PROFILE_USB_REGISTER_CONTEXT > *)Context)->Type)); > - Print(L" UsbDevicePath=3D\"%s\"", > ConvertDevicePathToText((EFI_DEVICE_PATH_PROTOCOL > *)(((SMI_HANDLER_PROFILE_USB_REGISTER_CONTEXT *)Context) + 1), TRUE, > TRUE)); > + Str =3D ConvertDevicePathToText((EFI_DEVICE_PATH_PROTOCOL > *)(((SMI_HANDLER_PROFILE_USB_REGISTER_CONTEXT *)Context) + 1), TRUE, > TRUE); > + Print(L" UsbDevicePath=3D\"%s\"", Str); > + if (Str !=3D NULL) { > + FreePool (Str); > + } > } else { > Print(L" Context=3D\""); > 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 =3D ConvertDevicePathToText((EFI_DEVICE_PATH_PROTOCOL > *)(((SMI_HANDLER_PROFILE_USB_REGISTER_CONTEXT *)Context) + 1), TRUE, > TRUE); > + DEBUG ((DEBUG_INFO, " UsbDevicePath - %s\n", Str)); > + if (Str !=3D NULL) { > + FreePool (Str); > + } > } else { > DEBUG ((DEBUG_INFO, " Context - ")); > InternalDumpData (Context, ContextSize); > -- > 2.7.0.windows.1