mirror of https://github.com/acidanthera/audk.git
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 <ting.ye@intel.com> Cc: Fu Siyuan <siyuan.fu@intel.com> Cc: Wu Jiaxin <jiaxin.wu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Zhang Lubo <lubo.zhang@intel.com> Reviewed-By: Wu Jiaxin <jiaxin.wu@intel.com>
This commit is contained in:
parent
3460c75dfe
commit
7c275b3cde
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -1987,7 +1987,11 @@ IScsiFormExtractConfig (
|
|||
ConfigRequestHdr = HiiConstructConfigHdr (&gIScsiConfigGuid, mVendorStorageName, Private->DriverHandle);
|
||||
Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);
|
||||
ConfigRequest = AllocateZeroPool (Size);
|
||||
ASSERT (ConfigRequest != NULL);
|
||||
if (ConfigRequest == NULL) {
|
||||
FreePool (IfrNvData);
|
||||
FreePool (InitiatorName);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
AllocatedRequest = TRUE;
|
||||
UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize);
|
||||
FreePool (ConfigRequestHdr);
|
||||
|
|
|
@ -323,6 +323,7 @@ IScsiSupported (
|
|||
@retval EFI_INVALID_PARAMETER Any input parameter is invalid.
|
||||
@retval EFI_NOT_FOUND There is no sufficient information to establish
|
||||
the iScsi session.
|
||||
@retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
|
||||
@retval EFI_DEVICE_ERROR Failed to get TCP connection device path.
|
||||
@retval EFI_ACCESS_DENIED The protocol could not be removed from the Handle
|
||||
because its interfaces are being used.
|
||||
|
|
|
@ -1006,6 +1006,7 @@ IScsiDhcpIsConfigured (
|
|||
|
||||
@retval EFI_SUCCESS The configuration data is retrieved.
|
||||
@retval EFI_NOT_FOUND This iSCSI driver is not configured yet.
|
||||
@retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
|
@ -1292,7 +1293,9 @@ IScsiGetConfigData (
|
|||
mPrivate->PortString,
|
||||
NULL
|
||||
);
|
||||
ASSERT (AttemptConfigData->AttemptTitleHelpToken != 0);
|
||||
if (AttemptConfigData->AttemptTitleHelpToken == 0) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
//
|
||||
// Record the attempt in global link list.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/** @file
|
||||
The implementation of iSCSI protocol based on RFC3720.
|
||||
|
||||
Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>
|
||||
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
|
||||
|
@ -731,7 +731,10 @@ IScsiPrepareLoginReq (
|
|||
}
|
||||
|
||||
LoginReq = (ISCSI_LOGIN_REQUEST *) NetbufAllocSpace (Nbuf, sizeof (ISCSI_LOGIN_REQUEST), NET_BUF_TAIL);
|
||||
ASSERT (LoginReq != NULL);
|
||||
if (LoginReq == NULL) {
|
||||
NetbufFree (Nbuf);
|
||||
return NULL;
|
||||
}
|
||||
ZeroMem (LoginReq, sizeof (ISCSI_LOGIN_REQUEST));
|
||||
|
||||
//
|
||||
|
@ -1245,7 +1248,10 @@ IScsiReceivePdu (
|
|||
}
|
||||
|
||||
Header = NetbufAllocSpace (PduHdr, Len, NET_BUF_TAIL);
|
||||
ASSERT (Header != NULL);
|
||||
if (Header == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
InsertTailList (NbufList, &PduHdr->List);
|
||||
|
||||
//
|
||||
|
@ -2316,7 +2322,10 @@ IScsiNewDataOutPdu (
|
|||
InsertTailList (NbufList, &PduHdr->List);
|
||||
|
||||
DataOutHdr = (ISCSI_SCSI_DATA_OUT *) NetbufAllocSpace (PduHdr, sizeof (ISCSI_SCSI_DATA_OUT), NET_BUF_TAIL);
|
||||
ASSERT (DataOutHdr != NULL);
|
||||
if (DataOutHdr == NULL) {
|
||||
IScsiFreeNbufList (NbufList);
|
||||
return NULL;
|
||||
}
|
||||
XferContext = &Tcb->XferContext;
|
||||
|
||||
ZeroMem (DataOutHdr, sizeof (ISCSI_SCSI_DATA_OUT));
|
||||
|
|
Loading…
Reference in New Issue