public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v1] MdeModulePkg/DxeCore: Please static checker for false report
@ 2019-04-22  7:24 Wu, Hao A
  2019-04-22 14:40 ` Michael D Kinney
  0 siblings, 1 reply; 6+ messages in thread
From: Wu, Hao A @ 2019-04-22  7:24 UTC (permalink / raw)
  To: devel; +Cc: Hao Wu, Ard Biesheuvel, Michael D Kinney, Liming Gao, Jian J Wang

After commit 57df17fe26, some static check reports suspicous NULL pointer
deference at line:

  Entry->MachineType = Entry->Emulator->MachineType;
                       ^^^^^^^^^^^^^^^

within function PeCoffEmuProtocolNotify().

However, 'Entry->Emulator' is guaranteed to have a non-NULL value when
previous call to the CoreHandleProtocol() returns EFI_SUCCESS.

Thus, in order to please the static checker, this commit will add an
ASSERT right before the false-positive NULL pointer dereference report.

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
---
 MdeModulePkg/Core/Dxe/Image/Image.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/MdeModulePkg/Core/Dxe/Image/Image.c b/MdeModulePkg/Core/Dxe/Image/Image.c
index 08306a73fd..546fa96eee 100644
--- a/MdeModulePkg/Core/Dxe/Image/Image.c
+++ b/MdeModulePkg/Core/Dxe/Image/Image.c
@@ -166,6 +166,13 @@ PeCoffEmuProtocolNotify (
                (VOID **)&Entry->Emulator
                );
     ASSERT_EFI_ERROR (Status);
+    //
+    // When the above CoreHandleProtocol() call returns with EFI_SUCCESS,
+    // 'Entry->Emulator' is guaranteed to have a non-NULL value.
+    // The below ASSERT is for addressing a false positive NULL pointer
+    // dereference issue raised from static analysis.
+    //
+    ASSERT (Entry->Emulator != NULL)
 
     Entry->MachineType = Entry->Emulator->MachineType;
 
-- 
2.12.0.windows.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-04-22 23:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-04-22  7:24 [PATCH v1] MdeModulePkg/DxeCore: Please static checker for false report Wu, Hao A
2019-04-22 14:40 ` Michael D Kinney
2019-04-22 21:25   ` Ard Biesheuvel
2019-04-22 21:53     ` Michael D Kinney
2019-04-22 22:02       ` [edk2-devel] " Ard Biesheuvel
2019-04-22 23:14         ` Andrew Fish

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox