qmp_inject_ghes_v2_error() fails to report two error conditions:
- When acpi_ghes_get_state() returns NULL (no ACPI GED device, or the
firmware has not yet reported the GHES addresses) the function
returns without setting errp, so the QMP caller sees a spurious
success although nothing was injected. Report it with
"GHES is not available".
- When qbase64_decode() fails, it has already stored an error in errp
describing the actual problem. Calling error_setg() again on the
same errp violates the Error API contract: an errp that already
holds an error must not be overwritten, since that leaks the first
Error object and discards the accurate message. Drop the redundant
error_setg() and let the decode error propagate unchanged.
With this, the QMP command reliably fails with a meaningful error
message whenever injection is not possible.
Fixes: ddd8f3baa27d ("qapi/acpi-hest: add an interface to do generic CPER error
injection")
Signed-off-by: Ren Yanyi <[email protected]>
---
hw/acpi/ghes_cper.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/acpi/ghes_cper.c b/hw/acpi/ghes_cper.c
index 31cb2ffabe..1516a7eb24 100644
--- a/hw/acpi/ghes_cper.c
+++ b/hw/acpi/ghes_cper.c
@@ -25,12 +25,12 @@ void qmp_inject_ghes_v2_error(const char *qmp_cper, Error
**errp)
ags = acpi_ghes_get_state();
if (!ags) {
+ error_setg(errp, "GHES is not available");
return;
}
cper = qbase64_decode(qmp_cper, -1, &len, errp);
if (!cper) {
- error_setg(errp, "missing GHES CPER payload");
return;
}