From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 14D8874004C for ; Mon, 23 Oct 2023 09:06:20 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=nIdkCDTW6BSOi+muK6Ys+CGY7kP63XD7oL0zllW5DJw=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1698051979; v=1; b=LcJvZVkk0XG1ICF8i068vBNEP4H5ro6BwPFMp9/SdqkTQxc2jU0cx3RGL4JRsoz5vG21zpLv go8KSUEYTMANRbWxVp1Byp7rWczpcLccg8Ku2CTcGR7FfmcsXAvjZblhyGgnGcR3cwLdaA9k2Rl Tzw80tfA7bc9dHaMpKGJMCLo= X-Received: by 127.0.0.2 with SMTP id 6YnPYY7687511x67b3lLidTi; Mon, 23 Oct 2023 02:06:19 -0700 X-Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web11.116698.1698051978991462874 for ; Mon, 23 Oct 2023 02:06:19 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10871"; a="385680781" X-IronPort-AV: E=Sophos;i="6.03,244,1694761200"; d="scan'208";a="385680781" X-Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Oct 2023 02:05:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10871"; a="758087957" X-IronPort-AV: E=Sophos;i="6.03,244,1694761200"; d="scan'208";a="758087957" X-Received: from cepingsx-mobl1.ccr.corp.intel.com ([10.239.49.140]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Oct 2023 02:05:52 -0700 From: "sunceping" To: devel@edk2.groups.io Cc: Ceping Sun , Erdem Aktas , James Bottomley , Jiewen Yao , Min Xu , Tom Lendacky , Michael Roth , Gerd Hoffmann Subject: [edk2-devel] [PATCH V2 1/1] OvmfPkg/AcpiPlatformDxe: Fix Coverity report issues Date: Mon, 23 Oct 2023 17:05:39 +0800 Message-Id: <20231023090539.1003-1-cepingx.sun@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,cepingx.sun@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: av3OQ3GVqOYeihQlLBHf03gQx7686176AA= Content-Transfer-Encoding: 8bit X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=LcJvZVkk; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io From: Ceping Sun v1 -> v2 Changed list: 1:Since both commits are intended to fix coverity issues, they are merged into one 2: Changed the debug info level to debug error when "DsdtTable == NULL" 3:Add the Cc member as below Erdem Aktas erdemaktas@google.com James Bottomley jejb@linux.ibm.com Tom Lendacky thomas.lendacky@amd.com Michael Roth michael.roth@amd.com REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4568 The function InstallCloudHvTablesTdx had an Assert when "DsdtTable == NULL", but this comes into play only in DEBUG mode. In Release mode , there is no handling if the pointer is NULL. To avoid the possible null pointer dereference, it is better to handle it when the pointer is null. In addition, the status of "AcpiProtocol->InstallAcpiTable" is overwritten before it can be used in the function, it is better to check it before overwriting. code: https://github.com/sunceping/edk2/tree/fixcoverityerrors.v2 Cc: Erdem Aktas Cc: James Bottomley Cc: Jiewen Yao Cc: Min Xu Cc: Tom Lendacky Cc: Michael Roth Cc: Gerd Hoffmann Signed-off-by: Ceping Sun --- OvmfPkg/AcpiPlatformDxe/CloudHvAcpi.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/AcpiPlatformDxe/CloudHvAcpi.c b/OvmfPkg/AcpiPlatformDxe/CloudHvAcpi.c index d3e73c155e8f..4629fa260366 100644 --- a/OvmfPkg/AcpiPlatformDxe/CloudHvAcpi.c +++ b/OvmfPkg/AcpiPlatformDxe/CloudHvAcpi.c @@ -53,6 +53,11 @@ InstallCloudHvTablesTdx ( CurrentTable->Length, &TableHandle ); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + return Status; + } + for (UINTN i = 0; i < CurrentTable->Length; i++) { DEBUG ((DEBUG_INFO, " %x", *((UINT8 *)CurrentTable + i))); } @@ -69,8 +74,9 @@ InstallCloudHvTablesTdx ( // then we're out of sync with the hypervisor, and cannot continue. // if (DsdtTable == NULL) { - DEBUG ((DEBUG_INFO, "%a: no DSDT found\n", __func__)); + DEBUG ((DEBUG_ERROR, "%a: no DSDT found\n", __func__)); ASSERT (FALSE); + CpuDeadLoop (); } Status = AcpiProtocol->InstallAcpiTable ( -- 2.34.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#109905): https://edk2.groups.io/g/devel/message/109905 Mute This Topic: https://groups.io/mt/102131520/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-