From nobody Mon Dec 23 13:29:41 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.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 1515460756310285.9483606086163; Mon, 8 Jan 2018 17:19:16 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id BAE342035D33E; Mon, 8 Jan 2018 17:14:04 -0800 (PST) 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 5A38C2035D336 for ; Mon, 8 Jan 2018 17:14:03 -0800 (PST) Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Jan 2018 17:19:13 -0800 Received: from fanwang2-hp.ccr.corp.intel.com ([10.239.9.33]) by fmsmga007.fm.intel.com with ESMTP; 08 Jan 2018 17:19:12 -0800 X-Original-To: edk2-devel@lists.01.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; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.65; helo=mga03.intel.com; envelope-from=fan.wang@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,333,1511856000"; d="scan'208";a="8181724" From: Wang Fan To: edk2-devel@lists.01.org Date: Tue, 9 Jan 2018 09:19:06 +0800 Message-Id: <1515460747-8372-2-git-send-email-fan.wang@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1515460747-8372-1-git-send-email-fan.wang@intel.com> References: <1515460747-8372-1-git-send-email-fan.wang@intel.com> Subject: [edk2] [Patch 1/2] MdeModulePkg: Fixed two issues when error occurs in Mtftp4Start. 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: , Cc: Ye Ting , Fu Siyuan , Jiaxin Wu 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" * This function sets returned status as token status and signal token when error occurs, and it results token status not compliance with spec definition. This patch fixed this issue. * This function restore Tpl twice when Mtftp4WrqStart() returns an error, this patch fixed this issue. Cc: Jiaxin Wu Cc: Ye Ting Cc: Fu Siyuan Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wang Fan Reviewed-by: Fu Siyuan Reviewed-by: Jiaxin Wu --- .../Universal/Network/Mtftp4Dxe/Mtftp4Impl.c | 20 ++++++++++++----= ---- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c b/MdeMod= ulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c index 54384e1..f5f9e6d 100644 --- a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c +++ b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c @@ -1,10 +1,10 @@ /** @file Interface routine for Mtftp4. =20 (C) Copyright 2014 Hewlett-Packard Development Company, L.P.
-Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD = License which accompanies this distribution. The full text of the license may be = found at http://opensource.org/licenses/bsd-license.php
=20 @@ -407,31 +407,33 @@ Mtftp4Start ( if (EFI_ERROR (Status)) { gBS->RestoreTPL (OldTpl); return Status; } =20 + if ((Token->OverrideData !=3D NULL) && !Mtftp4OverrideValid (Instance, T= oken->OverrideData)) { + Status =3D EFI_INVALID_PARAMETER; + gBS->RestoreTPL (OldTpl); + return Status; + } + // // Set the Operation now to prevent the application start other // operations. // Instance->Operation =3D Operation; Override =3D Token->OverrideData; =20 - if ((Override !=3D NULL) && !Mtftp4OverrideValid (Instance, Override)) { - Status =3D EFI_INVALID_PARAMETER; - goto ON_ERROR; - } - if (Token->OptionCount !=3D 0) { Status =3D Mtftp4ParseOption ( Token->OptionList, Token->OptionCount, TRUE, &Instance->RequestOption ); =20 if (EFI_ERROR (Status)) { + Status =3D EFI_DEVICE_ERROR; goto ON_ERROR; } } =20 // @@ -482,10 +484,11 @@ Mtftp4Start ( // Config the unicast UDP child to send initial request // Status =3D Mtftp4ConfigUnicastPort (Instance->UnicastPort, Instance); =20 if (EFI_ERROR (Status)) { + Status =3D EFI_DEVICE_ERROR; goto ON_ERROR; } =20 // // Set initial status. @@ -499,17 +502,17 @@ Mtftp4Start ( Status =3D Mtftp4WrqStart (Instance, Operation); } else { Status =3D Mtftp4RrqStart (Instance, Operation); } =20 - gBS->RestoreTPL (OldTpl); - if (EFI_ERROR (Status)) { + Status =3D EFI_DEVICE_ERROR; goto ON_ERROR; } =20 if (Token->Event !=3D NULL) { + gBS->RestoreTPL (OldTpl); return EFI_SUCCESS; } =20 // // Return immediately for asynchronous operation or poll the @@ -517,10 +520,11 @@ Mtftp4Start ( // while (Token->Status =3D=3D EFI_NOT_READY) { This->Poll (This); } =20 + gBS->RestoreTPL (OldTpl); return Token->Status; =20 ON_ERROR: Mtftp4CleanOperation (Instance, Status); gBS->RestoreTPL (OldTpl); --=20 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Mon Dec 23 13:29:41 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.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 1515460758692131.8659354749807; Mon, 8 Jan 2018 17:19:18 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 2A96F21CB87BC; Mon, 8 Jan 2018 17:14:07 -0800 (PST) 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 B18D32035D32C for ; Mon, 8 Jan 2018 17:14:05 -0800 (PST) Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Jan 2018 17:19:15 -0800 Received: from fanwang2-hp.ccr.corp.intel.com ([10.239.9.33]) by fmsmga007.fm.intel.com with ESMTP; 08 Jan 2018 17:19:14 -0800 X-Original-To: edk2-devel@lists.01.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; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.65; helo=mga03.intel.com; envelope-from=fan.wang@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,333,1511856000"; d="scan'208";a="8181735" From: Wang Fan To: edk2-devel@lists.01.org Date: Tue, 9 Jan 2018 09:19:07 +0800 Message-Id: <1515460747-8372-3-git-send-email-fan.wang@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1515460747-8372-1-git-send-email-fan.wang@intel.com> References: <1515460747-8372-1-git-send-email-fan.wang@intel.com> Subject: [edk2] [Patch 2/2] MdeModulePkg: Freed packet buffer when error occurs to avoid memory leak. 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: , Cc: Ye Ting , Fu Siyuan , Jiaxin Wu 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" * In function Mtftp4WrqSendBlock(), when packet is not needed, function returns EFI_ABORTED but not freed the packet buffer. It results some memory leak and this patch is to fix this issue. Cc: Jiaxin Wu Cc: Ye Ting Cc: Fu Siyuan Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wang Fan Reviewed-by: Fu Siyuan Reviewed-by: Jiaxin Wu --- MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Wrq.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Wrq.c b/MdeModu= lePkg/Universal/Network/Mtftp4Dxe/Mtftp4Wrq.c index e825714..438659a 100644 --- a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Wrq.c +++ b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Wrq.c @@ -1,9 +1,9 @@ /** @file Routines to process Wrq (upload). =20 -Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD = License which accompanies this distribution. The full text of the license may be = found at http://opensource.org/licenses/bsd-license.php
=20 @@ -92,10 +92,14 @@ Mtftp4WrqSendBlock ( if (EFI_ERROR (Status) || (DataLen > Instance->BlkSize)) { if (DataBuf !=3D NULL) { FreePool (DataBuf); } =20 + if (UdpPacket !=3D NULL) { + NetbufFree (UdpPacket); + } + Mtftp4SendError ( Instance, EFI_MTFTP4_ERRORCODE_REQUEST_DENIED, (UINT8 *) "User aborted the transfer" ); --=20 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel