From nobody Mon May 6 13:24:43 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 151133375715961.0486730654294; Tue, 21 Nov 2017 22:55:57 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 99E4221B00DD6; Tue, 21 Nov 2017 22:51:38 -0800 (PST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (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 4213821B00DD6 for ; Tue, 21 Nov 2017 22:51:37 -0800 (PST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Nov 2017 22:55:53 -0800 Received: from fanwang2-hp.ccr.corp.intel.com ([10.239.9.117]) by orsmga003.jf.intel.com with ESMTP; 21 Nov 2017 22:55:51 -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.24; helo=mga09.intel.com; envelope-from=fan.wang@intel.com; receiver=edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,436,1505804400"; d="scan'208";a="5083158" From: fanwang2 To: edk2-devel@lists.01.org Date: Wed, 22 Nov 2017 14:55:41 +0800 Message-Id: <1511333741-7060-1-git-send-email-fan.wang@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 Subject: [edk2] [Patch] MdeModulePkg: Free NET_BUF data after it is sent out to avoid memory leak 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: Ye Ting , Wang Fan , 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" When build a DHCP message in function DhcpSendMessage() or DhcpRetransmit(), a new NET_BUF is created by the library of NetbufFromExt, but it's not freed after it is sent out. This patch is to fix this memory leak 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 --- MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c b/MdeModuleP= kg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c index 3898223..d90dc34 100644 --- a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c +++ b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c @@ -1397,23 +1397,22 @@ DhcpSendMessage ( EndPoint.LocalAddr.Addr[0] =3D DhcpSb->ClientAddr; UdpIo =3D DhcpSb->LeaseIoPort; } =20 ASSERT (UdpIo !=3D NULL); - NET_GET_REF (Wrap); - =20 + Status =3D UdpIoSendDatagram ( UdpIo,=20 Wrap,=20 &EndPoint,=20 NULL,=20 DhcpOnPacketSent,=20 DhcpSb ); =20 if (EFI_ERROR (Status)) { - NET_PUT_REF (Wrap); + NetbufFree (Wrap); return EFI_ACCESS_DENIED; } =20 return EFI_SUCCESS; } @@ -1475,22 +1474,21 @@ DhcpRetransmit ( UdpIo =3D DhcpSb->LeaseIoPort; } =20 ASSERT (UdpIo !=3D NULL); =20 - NET_GET_REF (Wrap); Status =3D UdpIoSendDatagram ( UdpIo, Wrap, &EndPoint, NULL, DhcpOnPacketSent, DhcpSb ); =20 if (EFI_ERROR (Status)) { - NET_PUT_REF (Wrap); + NetbufFree (Wrap); return EFI_ACCESS_DENIED; } =20 return EFI_SUCCESS; } --=20 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel