public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Sami Mujawar" <sami.mujawar@arm.com>
To: <devel@edk2.groups.io>
Cc: Sami Mujawar <sami.mujawar@arm.com>, <ard.biesheuvel@arm.com>,
	<jiewen.yao@intel.com>, <thomas.abraham@arm.com>,
	<Sughosh.Ganu@arm.com>, <Matteo.Carlini@arm.com>,
	<Ben.Adderson@arm.com>, <nd@arm.com>
Subject: [PATCH v2 06/26] StandaloneMmPkg: Fix ECC error 3002 in StandaloneMmCpu
Date: Thu, 17 Dec 2020 13:04:49 +0000	[thread overview]
Message-ID: <20201217130509.12568-7-sami.mujawar@arm.com> (raw)
In-Reply-To: <20201217130509.12568-1-sami.mujawar@arm.com>

Fix the ECC tool reported error "[3002] Non-Boolean comparisons
should use a compare operator".

Also fix the following:
 - add curly braces for 'if' condition statements to comply
   with the coding standard.
 - The value returned by GET_GUID_HOB_DATA() is stored in
   *HobData. Therefore, check *HobData against NULL. The
   original code was checking HobData which is incorrect.

Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
Acked-by: Jiewen Yao <Jiewen.yao@intel.com>
---

Notes:
    v2:
     - No code change. Resending patch with v2 series.           [SAMI]

 StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/EventHandle.c     | 19 +++++++++++++------
 StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.c | 11 +++++++----
 2 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/EventHandle.c b/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/EventHandle.c
index 6a25c4c54843ccdc2d745e8e537942d49b1d1141..9738e8bd60149efb45ef1b66139e0cec38b6c1fe 100644
--- a/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/EventHandle.c
+++ b/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/EventHandle.c
@@ -1,7 +1,7 @@
 /** @file
 
   Copyright (c) 2016 HP Development Company, L.P.
-  Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.
+  Copyright (c) 2016 - 2020, Arm Limited. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -84,12 +84,18 @@ PiMmStandaloneArmTfCpuDriverEntry (
   }
 
   // Perform parameter validation of NsCommBufferAddr
-  if (NsCommBufferAddr && (NsCommBufferAddr < mNsCommBuffer.PhysicalStart))
+  if (NsCommBufferAddr == (UINTN)NULL) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  if (NsCommBufferAddr < mNsCommBuffer.PhysicalStart) {
     return EFI_ACCESS_DENIED;
+  }
 
   if ((NsCommBufferAddr + sizeof (EFI_MM_COMMUNICATE_HEADER)) >=
-      (mNsCommBuffer.PhysicalStart + mNsCommBuffer.PhysicalSize))
+      (mNsCommBuffer.PhysicalStart + mNsCommBuffer.PhysicalSize)) {
     return EFI_INVALID_PARAMETER;
+  }
 
   // Find out the size of the buffer passed
   NsCommBufferSize = ((EFI_MM_COMMUNICATE_HEADER *) NsCommBufferAddr)->MessageLength +
@@ -97,9 +103,9 @@ PiMmStandaloneArmTfCpuDriverEntry (
 
   // perform bounds check.
   if (NsCommBufferAddr + NsCommBufferSize >=
-      mNsCommBuffer.PhysicalStart + mNsCommBuffer.PhysicalSize)
+      mNsCommBuffer.PhysicalStart + mNsCommBuffer.PhysicalSize) {
     return EFI_ACCESS_DENIED;
-
+  }
 
   // Now that the secure world can see the normal world buffer, allocate
   // memory to copy the communication buffer to the secure world.
@@ -192,8 +198,9 @@ PiMmCpuTpFwRootMmiHandler (
   ASSERT (CommBufferSize == NULL);
 
   CpuNumber = mMmst->CurrentlyExecutingCpu;
-  if (!PerCpuGuidedEventContext[CpuNumber])
+  if (PerCpuGuidedEventContext[CpuNumber] == NULL) {
     return EFI_NOT_FOUND;
+  }
 
   DEBUG ((DEBUG_INFO, "CommBuffer - 0x%x, CommBufferSize - 0x%x\n",
           PerCpuGuidedEventContext[CpuNumber],
diff --git a/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.c b/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.c
index 617babd5ab4bcb200ee10e19ec6f99c2ef163200..7c004c8013460bb7f1690351aa64eeaa9eab91dc 100644
--- a/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.c
+++ b/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.c
@@ -2,7 +2,7 @@
 
   Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
   Copyright (c) 2016 HP Development Company, L.P.
-  Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.
+  Copyright (c) 2016 - 2020, Arm Limited. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -53,16 +53,19 @@ GetGuidedHobData (
 {
   EFI_HOB_GUID_TYPE *Hob;
 
-  if (!HobList || !HobGuid || !HobData)
+  if ((HobList == NULL) || (HobGuid == NULL) || (HobData == NULL)) {
     return EFI_INVALID_PARAMETER;
+  }
 
   Hob = GetNextGuidHob (HobGuid, HobList);
-  if (!Hob)
+  if (Hob == NULL) {
     return EFI_NOT_FOUND;
+  }
 
   *HobData = GET_GUID_HOB_DATA (Hob);
-  if (!HobData)
+  if (*HobData == NULL) {
     return EFI_NOT_FOUND;
+  }
 
   return EFI_SUCCESS;
 }
-- 
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'


  parent reply	other threads:[~2020-12-17 13:06 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-17 13:04 [PATCH v2 00/26] Enable Core CI support for StandaloneMmPkg Sami Mujawar
2020-12-17 13:04 ` [PATCH v2 01/26] StandaloneMmPkg: Add library header files to DEC Sami Mujawar
2020-12-17 13:04 ` [PATCH v2 02/26] StandaloneMmPkg: Add library files to DSC Sami Mujawar
2020-12-17 13:04 ` [PATCH v2 03/26] StandaloneMmPkg: Fix spell check reported errors Sami Mujawar
2020-12-17 13:04 ` [PATCH v2 04/26] StandaloneMmPkg: Fix ECC error 9002 in Core dispatcher Sami Mujawar
2020-12-17 13:04 ` [PATCH v2 05/26] StandaloneMmPkg: Fix ECC error 1001 in SMM Memory pool management Sami Mujawar
2020-12-17 13:04 ` Sami Mujawar [this message]
2020-12-17 13:04 ` [PATCH v2 07/26] StandaloneMmPkg: Fix ECC error 4002 in FwVol helper Sami Mujawar
2020-12-17 13:04 ` [PATCH v2 08/26] StandaloneMmPkg: Fix ECC error 5007 in StandaloneMmCoreEntryPoint Sami Mujawar
2020-12-17 13:04 ` [PATCH v2 09/26] StandaloneMmPkg: Fix ECC error 5007 in StandaloneMmCpu Sami Mujawar
2020-12-17 13:04 ` [PATCH v2 10/26] StandaloneMmPkg: Fix ECC error 5007 in StandaloneMmCore Sami Mujawar
2020-12-17 13:04 ` [PATCH v2 11/26] StandaloneMmPkg: Fix ECC error 10014 in StandaloneMmCpu Sami Mujawar
2020-12-17 13:04 ` [PATCH v2 12/26] StandaloneMmPkg: Fix ECC error 4002 and 9002 in StandaloneMmCore Sami Mujawar
2020-12-17 13:04 ` [PATCH v2 13/26] StandaloneMmPkg: Fix ECC error 4002 in StandaloneMmCoreEntryPoint Sami Mujawar
2020-12-17 13:04 ` [PATCH v2 14/26] StandaloneMmPkg: Fix ECC error 9002 in StandaloneMmMemLib Sami Mujawar
2020-12-17 13:04 ` [PATCH v2 15/26] StandaloneMmPkg: Fix ECC error 9002 in StandaloneMmCoreEntryPoint Sami Mujawar
2020-12-17 13:04 ` [PATCH v2 16/26] StandaloneMmPkg: Fix ECC error 9003 " Sami Mujawar
2020-12-17 13:05 ` [PATCH v2 17/26] StandaloneMmPkg: Fix ECC error 4002 in StandaloneMmCpu Sami Mujawar
2020-12-17 13:05 ` [PATCH v2 18/26] StandaloneMmPkg: Fix ECC error 9001 " Sami Mujawar
2020-12-17 13:05 ` [PATCH v2 19/26] StandaloneMmPkg: Fix ECC error 9001 in Standalone MM Core Sami Mujawar
2020-12-17 13:05 ` [PATCH v2 20/26] StandaloneMmPkg: Fix ECC error 9002 in CoreMemoryAllocationLib Sami Mujawar
2020-12-17 13:05 ` [PATCH v2 21/26] StandaloneMmPkg: Fix ECC error 4002 in StandaloneMmCpu Sami Mujawar
2020-12-17 13:05 ` [PATCH v2 22/26] StandaloneMmPkg: Fix ECC error 8005 in StandaloneMmCoreEntryPoint Sami Mujawar
2020-12-17 13:05 ` [PATCH v2 23/26] StandaloneMmPkg: Remove dependency on ArmPlatformPkg.dec Sami Mujawar
2020-12-17 13:05 ` [PATCH v2 24/26] StandaloneMmPkg: Add EDK2 Core CI support Sami Mujawar
2020-12-17 13:05 ` [PATCH v2 25/26] .azurepipelines: Add StandaloneMmPkg to CI matrix Sami Mujawar
2020-12-17 13:05 ` [PATCH v2 26/26] .pytool: CI Settings to support StandaloneMmPkg Sami Mujawar
2020-12-24  1:34 ` 回复: [edk2-devel] [PATCH v2 00/26] Enable Core CI support for StandaloneMmPkg gaoliming
2021-01-04 12:50   ` [edk2-devel] " Sami Mujawar

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=20201217130509.12568-7-sami.mujawar@arm.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