Both the cases have ASSERTs checking that the value is greater than 0. Move the checks to the same location as the ASSERT. I'd also prefer if we return with a failure instead of forcing continuation of the function with an invalid value.
Thanks, Saloni Addressed above comments and made changes, please review the latest changes below and kindly review coverity changes for other modules too. Cc: Saloni Kasbekar <saloni.kasbe...@intel.com> Cc: Zachary Clark-williams <zachary.clark-willi...@intel.com> Signed-off-by: SanthoshKumarV <santhoshkum...@ami.com> --- NetworkPkg/MnpDxe/MnpConfig.c | 3 +++ NetworkPkg/MnpDxe/MnpIo.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/NetworkPkg/MnpDxe/MnpConfig.c b/NetworkPkg/MnpDxe/MnpConfig.c index 93587d53aa..12fc80ad0c 100644 --- a/NetworkPkg/MnpDxe/MnpConfig.c +++ b/NetworkPkg/MnpDxe/MnpConfig.c @@ -1304,6 +1304,9 @@ MnpStop ( NET_CHECK_SIGNATURE (MnpServiceData, MNP_SERVICE_DATA_SIGNATURE); MnpDeviceData = MnpServiceData->MnpDeviceData; ASSERT (MnpDeviceData->ConfiguredChildrenNumber > 0); + + if (MnpDeviceData->ConfiguredChildrenNumber <= 0) + return EFI_OUT_OF_RESOURCES; // // Configure the receive filters. diff --git a/NetworkPkg/MnpDxe/MnpIo.c b/NetworkPkg/MnpDxe/MnpIo.c index 087c879c46..24dfad10fa 100644 --- a/NetworkPkg/MnpDxe/MnpIo.c +++ b/NetworkPkg/MnpDxe/MnpIo.c @@ -326,6 +326,9 @@ MnpInstanceDeliverPacket ( ASSERT (Instance->RcvdPacketQueueSize != 0); + if (Instance->RcvdPacketQueueSize == 0) + return EFI_OUT_OF_RESOURCES; + RxDataWrap = NET_LIST_HEAD (&Instance->RcvdPacketQueue, MNP_RXDATA_WRAP, WrapEntry); if (RxDataWrap->Nbuf->RefCnt > 2) { // -- 2.42.0.windows.2 -The information contained in this message may be confidential and proprietary to American Megatrends (AMI). This communication is intended to be read only by the individual or entity to whom it is addressed or by their designee. If the reader of this message is not the intended recipient, you are on notice that any distribution of this message, in any form, is strictly prohibited. Please promptly notify the sender by reply e-mail or by telephone at 770-246-8600, and then delete or destroy all copies of the transmission. -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#119104): https://edk2.groups.io/g/devel/message/119104 Mute This Topic: https://groups.io/mt/106223813/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-