From nobody Sat Dec 28 11:30:25 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1494496613286163.08638613834557; Thu, 11 May 2017 02:56:53 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 340DC21A13493; Thu, 11 May 2017 02:56:51 -0700 (PDT) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (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 C7B4321A13493 for ; Thu, 11 May 2017 02:56:49 -0700 (PDT) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP; 11 May 2017 02:56:49 -0700 Received: from shwdeopenpsi068.ccr.corp.intel.com ([10.239.9.20]) by orsmga005.jf.intel.com with ESMTP; 11 May 2017 02:56:48 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,323,1491289200"; d="scan'208";a="98620328" From: Star Zeng To: edk2-devel@lists.01.org Date: Thu, 11 May 2017 17:56:47 +0800 Message-Id: <1494496607-99080-1-git-send-email-star.zeng@intel.com> X-Mailer: git-send-email 2.7.0.windows.1 Subject: [edk2] [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: , Cc: Jiewen Yao , Star Zeng MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D530 In DumpSmiChildContext() of SmiHandlerProfile.c and SmiHandlerProfileInfo.c, the return buffer from ConvertDevicePathToText() should be freed after used. Cc: Jiewen Yao Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Star Zeng Reviewed-by: jiewen.yao@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/SmiHandlerProfi= leInfo.c b/MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfile= Info.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_RE= GISTER_CONTEXT *)Context)->Type)); } else if (CompareGuid (HandlerType, &gEfiSmmUsbDispatch2ProtocolGuid)) { Print(L" UsbType=3D\"0x%x\"", UsbTypeToString(((SMI_HANDLER_PROFILE_US= B_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_HAN= DLER_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_REGISTE= R_CONTEXT *)Context)->Type)); } else if (CompareGuid (HandlerType, &gEfiSmmUsbDispatch2ProtocolGuid)) { DEBUG ((DEBUG_INFO, " UsbType - 0x%x\n", ((SMI_HANDLER_PROFILE_USB_RE= GISTER_CONTEXT *)Context)->Type)); - DEBUG ((DEBUG_INFO, " UsbDevicePath - %s\n", ConvertDevicePathToText(= (EFI_DEVICE_PATH_PROTOCOL *)(((SMI_HANDLER_PROFILE_USB_REGISTER_CONTEXT *)C= ontext) + 1), TRUE, TRUE))); + Str =3D ConvertDevicePathToText((EFI_DEVICE_PATH_PROTOCOL *)(((SMI_HAN= DLER_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); --=20 2.7.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel