Resolved Coverity Issues reported in SNP Dxe.
1.ComponentName.c (Overflow)
Expression "OffSet--", which is equal to 18446744073709551615, where "OffSet" 
is known to be equal to 0, underflows the type that receives it.
2.SnpUndi32GetStatus,SnpUndi32Initialize,SnpUndi32Transmit (Deadcode)
Execution is not reaching as always snp is not equal to NULL
As This pointer is compared with NULL in function start
Macro EFI_SIMPLE_NETWORK_DEV_FROM_THIS always return address in This pointer
3.PxeInit(Overflow)
Expression "Snp->TxRxBufferSize - 1U", where "Snp->TxRxBufferSize" is known to 
be equal to 0, underflows the type that receives it
4.SnpUndi32Reset (Not used Variable)
ExtendedVerification variable is assigned but not used in that function.hence 
assign

Cc: Saloni Kasbekar <saloni.kasbe...@intel.com>
Cc: Zachary Clark-williams <zachary.clark-willi...@intel.com>

Signed-off-by: SanthoshKumarV <santhoshkum...@ami.com>
---
 NetworkPkg/SnpDxe/ComponentName.c |  3 ++-
 NetworkPkg/SnpDxe/Get_status.c    |  3 ---
 NetworkPkg/SnpDxe/Initialize.c    | 17 +++++++----------
 NetworkPkg/SnpDxe/Reset.c         |  3 +--
 NetworkPkg/SnpDxe/Transmit.c      |  3 ---
 5 files changed, 10 insertions(+), 19 deletions(-)

diff --git a/NetworkPkg/SnpDxe/ComponentName.c 
b/NetworkPkg/SnpDxe/ComponentName.c
index cc4cc5bddb..7d1360ff46 100644
--- a/NetworkPkg/SnpDxe/ComponentName.c
+++ b/NetworkPkg/SnpDxe/ComponentName.c
@@ -267,7 +267,8 @@ UpdateName (
   //

   // Remove the last '-'

   //

-  OffSet--;

+  if (OffSet > 0)

+    OffSet--;

   OffSet += UnicodeSPrint (

               HandleName + OffSet,

               sizeof (HandleName) - OffSet * sizeof (CHAR16),

diff --git a/NetworkPkg/SnpDxe/Get_status.c b/NetworkPkg/SnpDxe/Get_status.c
index 14b678fd36..6f277eb1a4 100644
--- a/NetworkPkg/SnpDxe/Get_status.c
+++ b/NetworkPkg/SnpDxe/Get_status.c
@@ -218,9 +218,6 @@ SnpUndi32GetStatus (


   OldTpl = gBS->RaiseTPL (TPL_CALLBACK);



-  if (Snp == NULL) {

-    return EFI_DEVICE_ERROR;

-  }



   switch (Snp->Mode.State) {

     case EfiSimpleNetworkInitialized:

diff --git a/NetworkPkg/SnpDxe/Initialize.c b/NetworkPkg/SnpDxe/Initialize.c
index c219a1cb20..4a15ad1cbd 100644
--- a/NetworkPkg/SnpDxe/Initialize.c
+++ b/NetworkPkg/SnpDxe/Initialize.c
@@ -128,11 +128,13 @@ PxeInit (
       );



     if (Snp->TxRxBuffer != NULL) {

-      Snp->PciIo->FreeBuffer (

-                    Snp->PciIo,

-                    SNP_MEM_PAGES (Snp->TxRxBufferSize),

-                    (VOID *)Snp->TxRxBuffer

-                    );

+      if (Snp->TxRxBufferSize != 0) {

+        Snp->PciIo->FreeBuffer (

+                      Snp->PciIo,

+                      SNP_MEM_PAGES (Snp->TxRxBufferSize),

+                      (VOID *)Snp->TxRxBuffer

+                      );

+     }

     }



     Snp->TxRxBuffer = NULL;

@@ -196,11 +198,6 @@ SnpUndi32Initialize (


   OldTpl = gBS->RaiseTPL (TPL_CALLBACK);



-  if (Snp == NULL) {

-    EfiStatus = EFI_INVALID_PARAMETER;

-    goto ON_EXIT;

-  }

-

   switch (Snp->Mode.State) {

     case EfiSimpleNetworkStarted:

       break;

diff --git a/NetworkPkg/SnpDxe/Reset.c b/NetworkPkg/SnpDxe/Reset.c
index 2ff685376d..1257cb6d71 100644
--- a/NetworkPkg/SnpDxe/Reset.c
+++ b/NetworkPkg/SnpDxe/Reset.c
@@ -94,9 +94,8 @@ SnpUndi32Reset (


   //

   // Resolve Warning 4 unreferenced parameter problem

+  // ExtendedVerification is not implemented

   //

-  ExtendedVerification = 0;

-  DEBUG ((DEBUG_WARN, "ExtendedVerification = %d is not implemented!\n", 
ExtendedVerification));



   if (This == NULL) {

     return EFI_INVALID_PARAMETER;

diff --git a/NetworkPkg/SnpDxe/Transmit.c b/NetworkPkg/SnpDxe/Transmit.c
index e2c7467b86..1e4ef2a8c3 100644
--- a/NetworkPkg/SnpDxe/Transmit.c
+++ b/NetworkPkg/SnpDxe/Transmit.c
@@ -289,9 +289,6 @@ SnpUndi32Transmit (


   OldTpl = gBS->RaiseTPL (TPL_CALLBACK);



-  if (Snp == NULL) {

-    return EFI_DEVICE_ERROR;

-  }



   switch (Snp->Mode.State) {

     case EfiSimpleNetworkInitialized:

--
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 (#118789): https://edk2.groups.io/g/devel/message/118789
Mute This Topic: https://groups.io/mt/106016970/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to