From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 8767A21DFA917 for ; Mon, 27 Mar 2017 08:02:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1490626926; x=1522162926; h=from:to:cc:subject:date:message-id; bh=pS5dcrF3wxGfdPI/19P9waqA2eOqBazZeJLsn5g2UqQ=; b=aoiwpT9ZluiKUMLhGV7iwGpmYHtklIrh4NS09/k3/tN2G4oU4f1e2xUZ YbMrumc/+Alw7oxJYlsfnMllj3ZZ1g==; Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Mar 2017 08:02:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,231,1486454400"; d="scan'208";a="65543286" Received: from jyao1-mobl.ccr.corp.intel.com ([10.254.212.12]) by orsmga002.jf.intel.com with ESMTP; 27 Mar 2017 08:02:03 -0700 From: Jiewen Yao To: edk2-devel@lists.01.org Cc: Jeff Fan , Feng Tian , Star Zeng , Bret Barkelew Date: Mon, 27 Mar 2017 23:02:00 +0800 Message-Id: <1490626920-16316-1-git-send-email-jiewen.yao@intel.com> X-Mailer: git-send-email 2.7.4.windows.1 Subject: [PATCH] MdeModulePkg/SmmCore: Fix memory leak on Profile unregistered. 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: Mon, 27 Mar 2017 15:02:06 -0000 Issue reported at bugzillar 445. Cc: Jeff Fan Cc: Feng Tian Cc: Star Zeng Cc: Bret Barkelew Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jiewen Yao --- MdeModulePkg/Core/PiSmmCore/SmiHandlerProfile.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Core/PiSmmCore/SmiHandlerProfile.c b/MdeModulePkg/Core/PiSmmCore/SmiHandlerProfile.c index 1e36039..ad3b54a 100644 --- a/MdeModulePkg/Core/PiSmmCore/SmiHandlerProfile.c +++ b/MdeModulePkg/Core/PiSmmCore/SmiHandlerProfile.c @@ -1186,7 +1186,9 @@ SmiHandlerProfileRegisterHandler ( SmiEntry = SmmCoreFindHardwareSmiEntry (HandlerGuid, TRUE); if (SmiEntry == NULL) { - FreePool (SmiHandler->Context); + if (SmiHandler->Context != NULL) { + FreePool (SmiHandler->Context); + } FreePool (SmiHandler); return EFI_OUT_OF_RESOURCES; } @@ -1277,6 +1279,9 @@ SmiHandlerProfileUnregisterHandler ( SmiHandler = TargetSmiHandler; RemoveEntryList (&SmiHandler->Link); + if (SmiHandler->Context != NULL) { + FreePool (SmiHandler->Context); + } FreePool (SmiHandler); if (IsListEmpty (&SmiEntry->SmiHandlers)) { -- 2.7.4.windows.1