On Thu, 12 Nov 2026 at 07:54, Ren Yanyi <[email protected]> wrote:
>
> virt_acpi_build() gates HEST table construction on:
>
>     acpi_ged_state = ACPI_GED(vms->acpi_dev);
>     ags = &acpi_ged_state->ghes_state;
>     if (ags) {
>
> ags is the address of the ghes_state member of AcpiGedState and can
> never be NULL, so the check always passes.  Whether the GED device
> exists is a separate condition (has_ged also depends on firmware
> being loaded and on ACPI being enabled), so a machine started with
> ras=on but without a GED device reaches this code with a NULL
> acpi_ged_state; ags then holds a bogus non-NULL pointer and
> acpi_build_hest() dereferences it.
>
> Test vms->acpi_dev, the device the block actually depends on, so the
> HEST table is only built when the GED device exists.
>
> Fixes: 2e9c5c5bc85a ("acpi/ghes: prepare to change the way HEST offsets are 
> calculated")
> Signed-off-by: Ren Yanyi <[email protected]>
> ---
>  hw/arm/virt-acpi-build.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
> index d368913..45bdabd 100644
> --- a/hw/arm/virt-acpi-build.c
> +++ b/hw/arm/virt-acpi-build.c
> @@ -1414,7 +1414,7 @@ void virt_acpi_build(VirtMachineState *vms, 
> AcpiBuildTables *tables)
>
>          acpi_ged_state = ACPI_GED(vms->acpi_dev);
>          ags = &acpi_ged_state->ghes_state;
> -        if (ags) {
> +        if (vms->acpi_dev) {

Now we're not trying to check anything to do with the local variables
we just set up, we can move this check up, so that we say
"if (vms->ras && vms->acpi_dev) {".

thanks
-- PMM

Reply via email to