* [edk2-devel] [PATCH V1 0/2] OvmfPkg/AcpiPlatformDxe: Fix the coverity errors
@ 2023-10-19 6:21 sunceping
2023-10-19 6:21 ` [edk2-devel] [PATCH V1 1/2] OvmfPkg/AcpiPlatformDxe: Avoid possible NULL pointer dereference sunceping
2023-10-19 6:21 ` [edk2-devel] [PATCH V1 2/2] OvmfPkg/AcpiPlatformDxe: Check the status to ensure no error sunceping
0 siblings, 2 replies; 3+ messages in thread
From: sunceping @ 2023-10-19 6:21 UTC (permalink / raw)
To: devel; +Cc: sunceping, Gerd Hoffmann, Jiewen Yao, Min Xu
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4568
Coverity report 2 issues in OvmfPkg/AcpiPlatformDxe/CloudHvAcpi.c.
In the function InstallCloudHvTablesTdx, the pointer is already checked.
if (DsdtTable == NULL) {
DEBUG ((DEBUG_INFO, "%a: no DSDT found\n", __func__));
ASSERT (FALSE);
}
But this comes into play only in DEBUG mode, in Release mode, that would be an error
with dereferencing null pointer. Fix this by adding CpuDeadLoop() after assert.
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.v1
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Min Xu <min.m.xu@intel.com>
Signed-off-by: Ceping Sun <cepingx.sun@intel.com>
Ceping Sun (2):
OvmfPkg/AcpiPlatformDxe: Avoid possible NULL pointer dereference
OvmfPkg/AcpiPlatformDxe: Check the status to ensure no error
OvmfPkg/AcpiPlatformDxe/CloudHvAcpi.c | 6 ++++++
1 file changed, 6 insertions(+)
--
2.34.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#109791): https://edk2.groups.io/g/devel/message/109791
Mute This Topic: https://groups.io/mt/102055422/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 3+ messages in thread
* [edk2-devel] [PATCH V1 1/2] OvmfPkg/AcpiPlatformDxe: Avoid possible NULL pointer dereference
2023-10-19 6:21 [edk2-devel] [PATCH V1 0/2] OvmfPkg/AcpiPlatformDxe: Fix the coverity errors sunceping
@ 2023-10-19 6:21 ` sunceping
2023-10-19 6:21 ` [edk2-devel] [PATCH V1 2/2] OvmfPkg/AcpiPlatformDxe: Check the status to ensure no error sunceping
1 sibling, 0 replies; 3+ messages in thread
From: sunceping @ 2023-10-19 6:21 UTC (permalink / raw)
To: devel; +Cc: Ceping Sun, Gerd Hoffmann, Jiewen Yao, Min Xu
From: Ceping Sun <cepingx.sun@intel.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.
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Min Xu <min.m.xu@intel.com>
Signed-off-by: Ceping Sun <cepingx.sun@intel.com>
---
OvmfPkg/AcpiPlatformDxe/CloudHvAcpi.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/OvmfPkg/AcpiPlatformDxe/CloudHvAcpi.c b/OvmfPkg/AcpiPlatformDxe/CloudHvAcpi.c
index d3e73c155e8f..24c22bb646ca 100644
--- a/OvmfPkg/AcpiPlatformDxe/CloudHvAcpi.c
+++ b/OvmfPkg/AcpiPlatformDxe/CloudHvAcpi.c
@@ -71,6 +71,7 @@ InstallCloudHvTablesTdx (
if (DsdtTable == NULL) {
DEBUG ((DEBUG_INFO, "%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 (#109792): https://edk2.groups.io/g/devel/message/109792
Mute This Topic: https://groups.io/mt/102055424/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [edk2-devel] [PATCH V1 2/2] OvmfPkg/AcpiPlatformDxe: Check the status to ensure no error
2023-10-19 6:21 [edk2-devel] [PATCH V1 0/2] OvmfPkg/AcpiPlatformDxe: Fix the coverity errors sunceping
2023-10-19 6:21 ` [edk2-devel] [PATCH V1 1/2] OvmfPkg/AcpiPlatformDxe: Avoid possible NULL pointer dereference sunceping
@ 2023-10-19 6:21 ` sunceping
1 sibling, 0 replies; 3+ messages in thread
From: sunceping @ 2023-10-19 6:21 UTC (permalink / raw)
To: devel; +Cc: Ceping Sun, Gerd Hoffmann, Jiewen Yao, Min Xu
From: Ceping Sun <cepingx.sun@intel.com>
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4568
The status of "AcpiProtocol->InstallAcpiTable" is overwritten
before it can be used, it is better to check it before overwriting.
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Min Xu <min.m.xu@intel.com>
Signed-off-by: Ceping Sun <cepingx.sun@intel.com>
---
OvmfPkg/AcpiPlatformDxe/CloudHvAcpi.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/OvmfPkg/AcpiPlatformDxe/CloudHvAcpi.c b/OvmfPkg/AcpiPlatformDxe/CloudHvAcpi.c
index 24c22bb646ca..7e2adcaa82d3 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)));
}
--
2.34.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#109793): https://edk2.groups.io/g/devel/message/109793
Mute This Topic: https://groups.io/mt/102055425/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-10-19 6:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-19 6:21 [edk2-devel] [PATCH V1 0/2] OvmfPkg/AcpiPlatformDxe: Fix the coverity errors sunceping
2023-10-19 6:21 ` [edk2-devel] [PATCH V1 1/2] OvmfPkg/AcpiPlatformDxe: Avoid possible NULL pointer dereference sunceping
2023-10-19 6:21 ` [edk2-devel] [PATCH V1 2/2] OvmfPkg/AcpiPlatformDxe: Check the status to ensure no error sunceping
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox