From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.93; helo=mga11.intel.com; envelope-from=jiaxin.wu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 E7F9D208F7A23 for ; Wed, 20 Dec 2017 22:46:02 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Dec 2017 22:50:51 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,434,1508828400"; d="scan'208";a="4074946" Received: from jiaxinwu-mobl2.ccr.corp.intel.com ([10.239.196.141]) by fmsmga007.fm.intel.com with ESMTP; 20 Dec 2017 22:50:50 -0800 From: Jiaxin Wu To: edk2-devel@lists.01.org Cc: Wang Fan , Ye Ting , Fu Siyuan , Wu Jiaxin Date: Thu, 21 Dec 2017 14:50:46 +0800 Message-Id: <1513839047-15032-2-git-send-email-jiaxin.wu@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1513839047-15032-1-git-send-email-jiaxin.wu@intel.com> References: <1513839047-15032-1-git-send-email-jiaxin.wu@intel.com> Subject: [Patch 1/2] NetworkPkg/HttpBootDxe: Avoid the potential memory leak when eror happen. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Dec 2017 06:46:03 -0000 Cc: Wang Fan Cc: Ye Ting Cc: Fu Siyuan Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wu Jiaxin --- NetworkPkg/HttpBootDxe/HttpBootDhcp4.c | 3 +++ NetworkPkg/HttpBootDxe/HttpBootImpl.c | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/NetworkPkg/HttpBootDxe/HttpBootDhcp4.c b/NetworkPkg/HttpBootDxe/HttpBootDhcp4.c index a8cee04..421ce6e 100644 --- a/NetworkPkg/HttpBootDxe/HttpBootDhcp4.c +++ b/NetworkPkg/HttpBootDxe/HttpBootDhcp4.c @@ -420,10 +420,13 @@ HttpBootParseDhcp4Packet ( } else { if (!IsProxyOffer) { OfferType = IsDnsOffer ? HttpOfferTypeDhcpDns : HttpOfferTypeDhcpOnly; } else { + if (Cache4->UriParser != NULL) { + FreePool (Cache4->UriParser); + } return EFI_DEVICE_ERROR; } } Cache4->OfferType = OfferType; diff --git a/NetworkPkg/HttpBootDxe/HttpBootImpl.c b/NetworkPkg/HttpBootDxe/HttpBootImpl.c index 7f0616d..d4b46a6 100644 --- a/NetworkPkg/HttpBootDxe/HttpBootImpl.c +++ b/NetworkPkg/HttpBootDxe/HttpBootImpl.c @@ -120,12 +120,13 @@ HttpBootStart ( ) { UINTN Index; EFI_STATUS Status; CHAR8 *Uri; - + Uri = NULL; + if (Private == NULL || FilePath == NULL) { return EFI_INVALID_PARAMETER; } // @@ -152,10 +153,13 @@ HttpBootStart ( // // Restart is required, first stop then continue this start function. // Status = HttpBootStop (Private); if (EFI_ERROR (Status)) { + if (Uri != NULL) { + FreePool (Uri); + } return Status; } } else { // // Restart is not required. -- 1.9.5.msysgit.1