From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.93, mailfrom: hao.a.wu@intel.com) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by groups.io with SMTP; Mon, 22 Apr 2019 00:24:51 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Apr 2019 00:24:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,381,1549958400"; d="scan'208";a="225554173" Received: from shwdeopenpsi014.ccr.corp.intel.com ([10.239.9.8]) by orsmga001.jf.intel.com with ESMTP; 22 Apr 2019 00:24:48 -0700 From: "Wu, Hao A" To: devel@edk2.groups.io Cc: Hao Wu , Ard Biesheuvel , Michael D Kinney , Liming Gao , Jian J Wang Subject: [PATCH v1] MdeModulePkg/DxeCore: Please static checker for false report Date: Mon, 22 Apr 2019 15:24:47 +0800 Message-Id: <20190422072447.10548-1-hao.a.wu@intel.com> X-Mailer: git-send-email 2.12.0.windows.1 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 Cc: Michael D Kinney Cc: Liming Gao Cc: Jian J Wang Signed-off-by: Hao Wu --- 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