From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 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 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,436,1505804400"; d="scan'208";a="5083158" 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 From: fanwang2 To: edk2-devel@lists.01.org Cc: Jiaxin Wu , Ye Ting , Fu Siyuan , Wang Fan 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: [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: , X-List-Received-Date: Wed, 22 Nov 2017 06:51:37 -0000 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 --- MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c b/MdeModulePkg/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] = DhcpSb->ClientAddr; UdpIo = DhcpSb->LeaseIoPort; } ASSERT (UdpIo != NULL); - NET_GET_REF (Wrap); - + Status = UdpIoSendDatagram ( UdpIo, Wrap, &EndPoint, NULL, DhcpOnPacketSent, DhcpSb ); if (EFI_ERROR (Status)) { - NET_PUT_REF (Wrap); + NetbufFree (Wrap); return EFI_ACCESS_DENIED; } return EFI_SUCCESS; } @@ -1475,22 +1474,21 @@ DhcpRetransmit ( UdpIo = DhcpSb->LeaseIoPort; } ASSERT (UdpIo != NULL); - NET_GET_REF (Wrap); Status = UdpIoSendDatagram ( UdpIo, Wrap, &EndPoint, NULL, DhcpOnPacketSent, DhcpSb ); if (EFI_ERROR (Status)) { - NET_PUT_REF (Wrap); + NetbufFree (Wrap); return EFI_ACCESS_DENIED; } return EFI_SUCCESS; } -- 1.9.5.msysgit.1