public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ranbir Singh" <rsingh@ventanamicro.com>
To: devel@edk2.groups.io, rsingh@ventanamicro.com
Cc: Dandan Bi <dandan.bi@intel.com>,
	Liming Gao <gaoliming@byosoft.com.cn>,
	Veeresh Sangolli <veeresh.sangolli@dellteam.com>
Subject: [edk2-devel] [PATCH v1 5/5] MdeModulePkg/Core/Dxe: Fix UNUSED_VALUE Coverity issues
Date: Tue, 26 Sep 2023 12:09:58 +0530	[thread overview]
Message-ID: <20230926063958.313858-6-rsingh@ventanamicro.com> (raw)
In-Reply-To: <20230926063958.313858-1-rsingh@ventanamicro.com>

The return value after calls to functions CoreProcessFvImageFile,
CoreStartImage,  CoreGetDepexSectionAndPreProccess,
CoreInternalAddMemorySpace, CoreAddIoSpace, CoreAllocateMemorySpace
and CoreCloseProtocol is stored in Status, but it is not made of any
use and later Status gets overridden.

One option assuming this is deliberate, would be to remove the return
value storage in Status.
Otherwise, simply add appropriate debug messages conditionally.

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4219

Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Co-authored-by: Veeresh Sangolli <veeresh.sangolli@dellteam.com>
Signed-off-by: Ranbir Singh <Ranbir.Singh3@Dell.com>
Signed-off-by: Ranbir Singh <rsingh@ventanamicro.com>
---
 MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c | 15 +++++++++++++++
 MdeModulePkg/Core/Dxe/Gcd/Gcd.c               | 15 +++++++++++++++
 MdeModulePkg/Core/Dxe/Image/Image.c           |  3 +++
 3 files changed, 33 insertions(+)

diff --git a/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c b/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c
index cf9d55687766..f53a2513457a 100644
--- a/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c
+++ b/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c
@@ -506,6 +506,10 @@ CoreDispatcher (
         // Produce a firmware volume block protocol for FvImage so it gets dispatched from.
         //
         Status = CoreProcessFvImageFile (DriverEntry->Fv, DriverEntry->FvHandle, &DriverEntry->FileName);
+        if (EFI_ERROR (Status)) {
+          DEBUG ((DEBUG_DISPATCH, "Failed to produce a FVB protocol for Fv %p FvHandle %p and FileName %g.\n",
+            DriverEntry->Fv, DriverEntry->FvHandle, &DriverEntry->FileName));
+        }
       } else {
         REPORT_STATUS_CODE_WITH_EXTENDED_DATA (
           EFI_PROGRESS_CODE,
@@ -516,6 +520,10 @@ CoreDispatcher (
         ASSERT (DriverEntry->ImageHandle != NULL);
 
         Status = CoreStartImage (DriverEntry->ImageHandle, NULL, NULL);
+        if (EFI_ERROR (Status)) {
+          DEBUG ((DEBUG_DISPATCH, "Failed to transfer control to a loaded image's entry point for ImageHandle %p.\n",
+            DriverEntry->ImageHandle));
+        }
 
         REPORT_STATUS_CODE_WITH_EXTENDED_DATA (
           EFI_PROGRESS_CODE,
@@ -549,6 +557,13 @@ CoreDispatcher (
         // If Section Extraction Protocol did not let the Depex be read before retry the read
         //
         Status = CoreGetDepexSectionAndPreProccess (DriverEntry);
+        if (EFI_ERROR (Status)) {
+          if (Status == EFI_PROTOCOL_ERROR) {
+            DEBUG ((DEBUG_DISPATCH, "Section extraction protocol failure for DriverEntry %p.\n", DriverEntry));
+          } else {
+            DEBUG ((DEBUG_DISPATCH, "No Depex, assume UEFI 2.0 driver model for DriverEntry %p.\n", DriverEntry));
+          }
+        }
       }
 
       if (DriverEntry->Dependent) {
diff --git a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c
index 39fa2adf9366..384fee600d85 100644
--- a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c
+++ b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c
@@ -2638,6 +2638,9 @@ CoreInitializeGcdServices (
                    ResourceHob->ResourceLength,
                    Capabilities
                    );
+        if (EFI_ERROR (Status)) {
+          DEBUG ((DEBUG_GCD, "Failed to add a segment of memory to GCD map, Status = %r\n", Status));
+        }
       }
 
       if (GcdIoType != EfiGcdIoTypeNonExistent) {
@@ -2646,6 +2649,9 @@ CoreInitializeGcdServices (
                    ResourceHob->PhysicalStart,
                    ResourceHob->ResourceLength
                    );
+        if (EFI_ERROR (Status)) {
+          DEBUG ((DEBUG_GCD, "Failed to add reserved I/O or I/O resources, Status = %r\n", Status));
+        }
       }
     }
   }
@@ -2668,6 +2674,9 @@ CoreInitializeGcdServices (
                gDxeCoreImageHandle,
                NULL
                );
+    if (EFI_ERROR (Status)) {
+      DEBUG ((DEBUG_GCD, "Failed to allocate memory space, Status = %r\n", Status));
+    }
   }
 
   //
@@ -2715,6 +2724,9 @@ CoreInitializeGcdServices (
                             gDxeCoreImageHandle,
                             NULL
                             );
+      if (EFI_ERROR (Status)) {
+        DEBUG ((DEBUG_GCD, "Failed to allocate memory space, Status = %r\n", Status));
+      }
     }
   }
 
@@ -2763,6 +2775,9 @@ CoreInitializeGcdServices (
                    gDxeCoreImageHandle,
                    NULL
                    );
+        if (EFI_ERROR (Status)) {
+          DEBUG ((DEBUG_GCD, "Failed to allocate memory space, Status = %r\n", Status));
+        }
       }
     }
   }
diff --git a/MdeModulePkg/Core/Dxe/Image/Image.c b/MdeModulePkg/Core/Dxe/Image/Image.c
index 9dbfb2a1fad2..769e2d379051 100644
--- a/MdeModulePkg/Core/Dxe/Image/Image.c
+++ b/MdeModulePkg/Core/Dxe/Image/Image.c
@@ -1010,6 +1010,9 @@ CoreUnloadAndCloseImage (
                              Image->Handle,
                              OpenInfo[OpenInfoIndex].ControllerHandle
                              );
+                  if (EFI_ERROR (Status)) {
+                    DEBUG ((DEBUG_WARN, "Failed to close protocol on Handle %p\n", HandleBuffer[HandleIndex]));
+                  }
                 }
               }
 
-- 
2.34.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#109064): https://edk2.groups.io/g/devel/message/109064
Mute This Topic: https://groups.io/mt/101590758/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



      parent reply	other threads:[~2023-09-26  6:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-26  6:39 [edk2-devel] [PATCH v1 0/5] BZ 4219: MdeModulePkg/Core/Dxe: Fix issues Ranbir Singh
2023-09-26  6:39 ` [edk2-devel] [PATCH v1 1/5] MdeModulePkg/Core/Dxe: Fix FORWARD_NULL Coverity issues Ranbir Singh
2023-09-26  6:39 ` [edk2-devel] [PATCH v1 2/5] MdeModulePkg/Core/Dxe: Fix MISSING_BREAK Coverity issue Ranbir Singh
2023-09-26  6:39 ` [edk2-devel] [PATCH v1 3/5] MdeModulePkg/Core/Dxe: Fix DEADCODE " Ranbir Singh
2023-09-26  6:39 ` [edk2-devel] [PATCH v1 4/5] MdeModulePkg/Core/Dxe: Fix OVERFLOW_BEFORE_WIDEN Coverity issues Ranbir Singh
2023-09-26  6:39 ` Ranbir Singh [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230926063958.313858-6-rsingh@ventanamicro.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox