From 7c275b3cde5fdc3cf6fac068c52455927d09c1c1 Mon Sep 17 00:00:00 2001 From: Zhang Lubo Date: Tue, 21 Jun 2016 14:40:28 +0800 Subject: NetworkPkg: Replace ASSERT with error handling in Http boot and IScsi v2: *Fix some memory leak issue. This patch is used to replace ASSERT with error handling in Http boot Driver and IScsi driver. Cc: Ye Ting Cc: Fu Siyuan Cc: Wu Jiaxin Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Zhang Lubo Reviewed-By: Wu Jiaxin --- NetworkPkg/HttpBootDxe/HttpBootConfig.c | 5 +++-- NetworkPkg/HttpBootDxe/HttpBootDhcp6.c | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'NetworkPkg/HttpBootDxe') diff --git a/NetworkPkg/HttpBootDxe/HttpBootConfig.c b/NetworkPkg/HttpBootDxe/HttpBootConfig.c index 7ae2ff61f2..7c883b8397 100644 --- a/NetworkPkg/HttpBootDxe/HttpBootConfig.c +++ b/NetworkPkg/HttpBootDxe/HttpBootConfig.c @@ -273,7 +273,9 @@ HttpBootFormExtractConfig ( ConfigRequestHdr = HiiConstructConfigHdr (&gHttpBootConfigGuid, mHttpBootConfigStorageName, CallbackInfo->ChildHandle); Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16); ConfigRequest = AllocateZeroPool (Size); - ASSERT (ConfigRequest != NULL); + if (ConfigRequest == NULL) { + return EFI_OUT_OF_RESOURCES; + } AllocatedRequest = TRUE; UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize); FreePool (ConfigRequestHdr); @@ -464,7 +466,6 @@ HttpBootFormCallback ( // Get user input URI string // Uri = HiiGetString (CallbackInfo->RegisteredHandle, Value->string, NULL); - ASSERT (Uri != NULL); if (Uri == NULL) { return EFI_UNSUPPORTED; } diff --git a/NetworkPkg/HttpBootDxe/HttpBootDhcp6.c b/NetworkPkg/HttpBootDxe/HttpBootDhcp6.c index 0157095edf..9ea421d758 100644 --- a/NetworkPkg/HttpBootDxe/HttpBootDhcp6.c +++ b/NetworkPkg/HttpBootDxe/HttpBootDhcp6.c @@ -401,6 +401,7 @@ HttpBootCacheDhcp6Offer ( @retval EFI_NOT_READY Only used in the Dhcp6Selecting state. The EFI DHCPv6 Protocol driver will continue to wait for more packets. @retval EFI_ABORTED Told the EFI DHCPv6 Protocol driver to abort the current process. + @retval EFI_OUT_OF_RESOURCES There are not enough resources. **/ EFI_STATUS @@ -451,7 +452,9 @@ HttpBootDhcp6CallBack ( ASSERT (NewPacket != NULL); SelectAd = &Private->OfferBuffer[Private->SelectIndex - 1].Dhcp6.Packet.Offer; *NewPacket = AllocateZeroPool (SelectAd->Size); - ASSERT (*NewPacket != NULL); + if (*NewPacket == NULL) { + return EFI_OUT_OF_RESOURCES; + } CopyMem (*NewPacket, SelectAd, SelectAd->Size); } break; -- cgit v1.2.3