aboutsummaryrefslogtreecommitdiff
path: root/hw/acpi
diff options
context:
space:
mode:
authorAni Sinha <ani@anisinha.ca>2022-05-13 19:40:05 +0530
committerMichael S. Tsirkin <mst@redhat.com>2022-06-16 12:54:58 -0400
commit8c97e4deeca9ad791ab369d3879ebfb0267b24ca (patch)
tree357c9bca94e0d94203d8bc2ebaa967e5fc655377 /hw/acpi
parent9ce305c8beb9ba7edacd0585139cce56a195c1da (diff)
downloadqemu-8c97e4deeca9ad791ab369d3879ebfb0267b24ca.zip
qemu-8c97e4deeca9ad791ab369d3879ebfb0267b24ca.tar.gz
qemu-8c97e4deeca9ad791ab369d3879ebfb0267b24ca.tar.bz2
acpi/erst: fix fallthrough code upon validation failure
At any step when any validation fail in check_erst_backend_storage(), there is no need to continue further through other validation checks. Further, by continuing even when record_size is 0, we run the risk of triggering a divide by zero error if we continued with other validation checks. Hence, we should simply return from this function upon validation failure. CC: Peter Maydell <peter.maydell@linaro.org> CC: Eric DeVolder <eric.devolder@oracle.com> Signed-off-by: Ani Sinha <ani@anisinha.ca> Message-Id: <20220513141005.1929422-1-ani@anisinha.ca> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by: Eric DeVolder <eric.devolder@oracle.com>
Diffstat (limited to 'hw/acpi')
-rw-r--r--hw/acpi/erst.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/hw/acpi/erst.c b/hw/acpi/erst.c
index de509c2..df856b2 100644
--- a/hw/acpi/erst.c
+++ b/hw/acpi/erst.c
@@ -440,6 +440,7 @@ static void check_erst_backend_storage(ERSTDeviceState *s, Error **errp)
(record_size >= 4096) /* PAGE_SIZE */
)) {
error_setg(errp, "ERST record_size %u is invalid", record_size);
+ return;
}
/* Validity check header */
@@ -450,6 +451,7 @@ static void check_erst_backend_storage(ERSTDeviceState *s, Error **errp)
(le16_to_cpu(header->reserved) == 0)
)) {
error_setg(errp, "ERST backend storage header is invalid");
+ return;
}
/* Check storage_size against record_size */
@@ -457,6 +459,7 @@ static void check_erst_backend_storage(ERSTDeviceState *s, Error **errp)
(record_size > s->storage_size)) {
error_setg(errp, "ACPI ERST requires storage size be multiple of "
"record size (%uKiB)", record_size);
+ return;
}
/* Compute offset of first and last record storage slot */