* 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.
V2:
* Since packet has already been referred by DhcpSb->LastPacket, and will be
freed when sending another packet or clean up, there is no need to add an
extra free function in NetbufFromExt.
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wang Fan <fan.wang@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
RFC 1534: Interoperation Between DHCP and BOOTP\r
RFC 3396: Encoding Long Options in DHCP.\r
\r
RFC 1534: Interoperation Between DHCP and BOOTP\r
RFC 3396: Encoding Long Options in DHCP.\r
\r
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
IN OUT EFI_DHCP4_CONFIG_DATA *Config\r
);\r
\r
IN OUT EFI_DHCP4_CONFIG_DATA *Config\r
);\r
\r
+/**\r
+ Callback of Dhcp packet. Does nothing.\r
+\r
+ @param Arg The context.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+DhcpDummyExtFree (\r
+ IN VOID *Arg\r
+ );\r
+\r
/**\r
Set the elapsed time based on the given instance and the pointer to the\r
elapsed time option.\r
/**\r
Set the elapsed time based on the given instance and the pointer to the\r
elapsed time option.\r
/** @file\r
EFI DHCP protocol implementation.\r
\r
/** @file\r
EFI DHCP protocol implementation.\r
\r
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
-\r
-/**\r
- Release the packet.\r
-\r
- @param[in] Arg The packet to release\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-DhcpReleasePacket (\r
- IN VOID *Arg\r
- )\r
-{\r
- FreePool (Arg);\r
-}\r
-\r
-\r
/**\r
Release the net buffer when packet is sent.\r
\r
/**\r
Release the net buffer when packet is sent.\r
\r
Packet->Dhcp4.Header.HwAddrLen\r
);\r
\r
Packet->Dhcp4.Header.HwAddrLen\r
);\r
\r
//\r
// Wrap it into a netbuf then send it.\r
//\r
Frag.Bulk = (UINT8 *) &Packet->Dhcp4.Header;\r
Frag.Len = Packet->Length;\r
//\r
// Wrap it into a netbuf then send it.\r
//\r
Frag.Bulk = (UINT8 *) &Packet->Dhcp4.Header;\r
Frag.Len = Packet->Length;\r
- Wrap = NetbufFromExt (&Frag, 1, 0, 0, DhcpReleasePacket, Packet);\r
+ Wrap = NetbufFromExt (&Frag, 1, 0, 0, DhcpDummyExtFree, NULL);\r
\r
if (Wrap == NULL) {\r
FreePool (Packet);\r
\r
if (Wrap == NULL) {\r
FreePool (Packet);\r
}\r
\r
ASSERT (UdpIo != NULL);\r
}\r
\r
ASSERT (UdpIo != NULL);\r
\r
Status = UdpIoSendDatagram (\r
UdpIo, \r
\r
Status = UdpIoSendDatagram (\r
UdpIo, \r
);\r
\r
if (EFI_ERROR (Status)) {\r
);\r
\r
if (EFI_ERROR (Status)) {\r
return EFI_ACCESS_DENIED;\r
}\r
\r
return EFI_ACCESS_DENIED;\r
}\r
\r
//\r
Frag.Bulk = (UINT8 *) &DhcpSb->LastPacket->Dhcp4.Header;\r
Frag.Len = DhcpSb->LastPacket->Length;\r
//\r
Frag.Bulk = (UINT8 *) &DhcpSb->LastPacket->Dhcp4.Header;\r
Frag.Len = DhcpSb->LastPacket->Length;\r
- Wrap = NetbufFromExt (&Frag, 1, 0, 0, DhcpReleasePacket, DhcpSb->LastPacket);\r
+ Wrap = NetbufFromExt (&Frag, 1, 0, 0, DhcpDummyExtFree, NULL);\r
\r
if (Wrap == NULL) {\r
return EFI_OUT_OF_RESOURCES;\r
}\r
\r
if (Wrap == NULL) {\r
return EFI_OUT_OF_RESOURCES;\r
}\r
//\r
// Broadcast the message, unless we know the server address.\r
//\r
//\r
// Broadcast the message, unless we know the server address.\r
//\r
\r
ASSERT (UdpIo != NULL);\r
\r
\r
ASSERT (UdpIo != NULL);\r
\r
Status = UdpIoSendDatagram (\r
UdpIo,\r
Wrap,\r
Status = UdpIoSendDatagram (\r
UdpIo,\r
Wrap,\r
);\r
\r
if (EFI_ERROR (Status)) {\r
);\r
\r
if (EFI_ERROR (Status)) {\r
return EFI_ACCESS_DENIED;\r
}\r
\r
return EFI_ACCESS_DENIED;\r
}\r
\r