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:
@@ -273,7 +273,9 @@ HttpBootFormExtractConfig (
|
|||||||
ConfigRequestHdr = HiiConstructConfigHdr (&gHttpBootConfigGuid, mHttpBootConfigStorageName, CallbackInfo->ChildHandle);
|
ConfigRequestHdr = HiiConstructConfigHdr (&gHttpBootConfigGuid, mHttpBootConfigStorageName, CallbackInfo->ChildHandle);
|
||||||
Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);
|
Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);
|
||||||
ConfigRequest = AllocateZeroPool (Size);
|
ConfigRequest = AllocateZeroPool (Size);
|
||||||
ASSERT (ConfigRequest != NULL);
|
if (ConfigRequest == NULL) {
|
||||||
|
return EFI_OUT_OF_RESOURCES;
|
||||||
|
}
|
||||||
AllocatedRequest = TRUE;
|
AllocatedRequest = TRUE;
|
||||||
UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize);
|
UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize);
|
||||||
FreePool (ConfigRequestHdr);
|
FreePool (ConfigRequestHdr);
|
||||||
@@ -464,7 +466,6 @@ HttpBootFormCallback (
|
|||||||
// Get user input URI string
|
// Get user input URI string
|
||||||
//
|
//
|
||||||
Uri = HiiGetString (CallbackInfo->RegisteredHandle, Value->string, NULL);
|
Uri = HiiGetString (CallbackInfo->RegisteredHandle, Value->string, NULL);
|
||||||
ASSERT (Uri != NULL);
|
|
||||||
if (Uri == NULL) {
|
if (Uri == NULL) {
|
||||||
return EFI_UNSUPPORTED;
|
return EFI_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
@@ -401,6 +401,7 @@ HttpBootCacheDhcp6Offer (
|
|||||||
@retval EFI_NOT_READY Only used in the Dhcp6Selecting state. The EFI DHCPv6 Protocol
|
@retval EFI_NOT_READY Only used in the Dhcp6Selecting state. The EFI DHCPv6 Protocol
|
||||||
driver will continue to wait for more packets.
|
driver will continue to wait for more packets.
|
||||||
@retval EFI_ABORTED Told the EFI DHCPv6 Protocol driver to abort the current process.
|
@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
|
EFI_STATUS
|
||||||
@@ -451,7 +452,9 @@ HttpBootDhcp6CallBack (
|
|||||||
ASSERT (NewPacket != NULL);
|
ASSERT (NewPacket != NULL);
|
||||||
SelectAd = &Private->OfferBuffer[Private->SelectIndex - 1].Dhcp6.Packet.Offer;
|
SelectAd = &Private->OfferBuffer[Private->SelectIndex - 1].Dhcp6.Packet.Offer;
|
||||||
*NewPacket = AllocateZeroPool (SelectAd->Size);
|
*NewPacket = AllocateZeroPool (SelectAd->Size);
|
||||||
ASSERT (*NewPacket != NULL);
|
if (*NewPacket == NULL) {
|
||||||
|
return EFI_OUT_OF_RESOURCES;
|
||||||
|
}
|
||||||
CopyMem (*NewPacket, SelectAd, SelectAd->Size);
|
CopyMem (*NewPacket, SelectAd, SelectAd->Size);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@@ -1987,7 +1987,11 @@ IScsiFormExtractConfig (
|
|||||||
ConfigRequestHdr = HiiConstructConfigHdr (&gIScsiConfigGuid, mVendorStorageName, Private->DriverHandle);
|
ConfigRequestHdr = HiiConstructConfigHdr (&gIScsiConfigGuid, mVendorStorageName, Private->DriverHandle);
|
||||||
Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);
|
Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);
|
||||||
ConfigRequest = AllocateZeroPool (Size);
|
ConfigRequest = AllocateZeroPool (Size);
|
||||||
ASSERT (ConfigRequest != NULL);
|
if (ConfigRequest == NULL) {
|
||||||
|
FreePool (IfrNvData);
|
||||||
|
FreePool (InitiatorName);
|
||||||
|
return EFI_OUT_OF_RESOURCES;
|
||||||
|
}
|
||||||
AllocatedRequest = TRUE;
|
AllocatedRequest = TRUE;
|
||||||
UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize);
|
UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize);
|
||||||
FreePool (ConfigRequestHdr);
|
FreePool (ConfigRequestHdr);
|
||||||
|
@@ -323,6 +323,7 @@ IScsiSupported (
|
|||||||
@retval EFI_INVALID_PARAMETER Any input parameter is invalid.
|
@retval EFI_INVALID_PARAMETER Any input parameter is invalid.
|
||||||
@retval EFI_NOT_FOUND There is no sufficient information to establish
|
@retval EFI_NOT_FOUND There is no sufficient information to establish
|
||||||
the iScsi session.
|
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_DEVICE_ERROR Failed to get TCP connection device path.
|
||||||
@retval EFI_ACCESS_DENIED The protocol could not be removed from the Handle
|
@retval EFI_ACCESS_DENIED The protocol could not be removed from the Handle
|
||||||
because its interfaces are being used.
|
because its interfaces are being used.
|
||||||
|
@@ -1006,6 +1006,7 @@ IScsiDhcpIsConfigured (
|
|||||||
|
|
||||||
@retval EFI_SUCCESS The configuration data is retrieved.
|
@retval EFI_SUCCESS The configuration data is retrieved.
|
||||||
@retval EFI_NOT_FOUND This iSCSI driver is not configured yet.
|
@retval EFI_NOT_FOUND This iSCSI driver is not configured yet.
|
||||||
|
@retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
@@ -1292,7 +1293,9 @@ IScsiGetConfigData (
|
|||||||
mPrivate->PortString,
|
mPrivate->PortString,
|
||||||
NULL
|
NULL
|
||||||
);
|
);
|
||||||
ASSERT (AttemptConfigData->AttemptTitleHelpToken != 0);
|
if (AttemptConfigData->AttemptTitleHelpToken == 0) {
|
||||||
|
return EFI_OUT_OF_RESOURCES;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Record the attempt in global link list.
|
// Record the attempt in global link list.
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
/** @file
|
/** @file
|
||||||
The implementation of iSCSI protocol based on RFC3720.
|
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
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
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);
|
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));
|
ZeroMem (LoginReq, sizeof (ISCSI_LOGIN_REQUEST));
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -1245,7 +1248,10 @@ IScsiReceivePdu (
|
|||||||
}
|
}
|
||||||
|
|
||||||
Header = NetbufAllocSpace (PduHdr, Len, NET_BUF_TAIL);
|
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);
|
InsertTailList (NbufList, &PduHdr->List);
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -2316,7 +2322,10 @@ IScsiNewDataOutPdu (
|
|||||||
InsertTailList (NbufList, &PduHdr->List);
|
InsertTailList (NbufList, &PduHdr->List);
|
||||||
|
|
||||||
DataOutHdr = (ISCSI_SCSI_DATA_OUT *) NetbufAllocSpace (PduHdr, sizeof (ISCSI_SCSI_DATA_OUT), NET_BUF_TAIL);
|
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;
|
XferContext = &Tcb->XferContext;
|
||||||
|
|
||||||
ZeroMem (DataOutHdr, sizeof (ISCSI_SCSI_DATA_OUT));
|
ZeroMem (DataOutHdr, sizeof (ISCSI_SCSI_DATA_OUT));
|
||||||
|
Reference in New Issue
Block a user