Skip to contentSkip to conversation

acpi: avoid potential uninitialized access to cpu_hp_io_base

PATCH In review Daniel P. Berrange 2 participants 2 messages Jul 31, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 acpi: avoid potential uninitialized access to cpu_hp_io_base

When building QEMU with Mingw64 toolchain I see a warning

CC x86_64-softmmu/hw/i386/acpi-build.o
hw/i386/acpi-build.c: In function 'acpi_build':
hw/i386/acpi-build.c:1138:9: warning: 'pm.cpu_hp_io_base' may be used uninitialized in this function [-Wmaybe-uninitialized]

           aml_append(crs,
           ^
  hw/i386/acpi-build.c:1666:16: note: 'pm.cpu_hp_io_base' was declared here
       AcpiPmInfo pm;
                  ^

In acpi_get_pm_info() some of the fields are pre-initialized to 0, but this one was missed.

---
 hw/i386/acpi-build.c | 1 +
 1 file changed, 1 insertion(+)
hw/i386/acpi-build.c +1 -0
index 46eddb8..95e0c65 100644
@@ -169,6 +169,7 @@ static void acpi_get_pm_info(AcpiPmInfo *pm)
     Object *obj = NULL;
     QObject *o;
 
+    pm->cpu_hp_io_base = 0;
     pm->pcihp_io_base = 0;
     pm->pcihp_io_len = 0;
     if (piix) {
Signature · 1 line
2.4.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · On Fri, 31 Jul 2015 11:14:35 +0100 "Daniel P. Berrange" <[email protected]>…

When building QEMU with Mingw64 toolchain I see a warning

CC x86_64-softmmu/hw/i386/acpi-build.o
hw/i386/acpi-build.c: In function 'acpi_build':
hw/i386/acpi-build.c:1138:9: warning: 'pm.cpu_hp_io_base' may be used uninitialized in this function [-Wmaybe-uninitialized]

           aml_append(crs,
           ^
  hw/i386/acpi-build.c:1666:16: note: 'pm.cpu_hp_io_base' was declared here
       AcpiPmInfo pm;
                  ^
Quoted 4 lines

In acpi_get_pm_info() some of the fields are pre-initialized to 0, but this one was missed.

Impossible in practice since piix or lpc branches will initialize it, but there is no harm in making compiler happy.

Quoted 16 lines
---
 hw/i386/acpi-build.c | 1 +
 1 file changed, 1 insertion(+)
hw/i386/acpi-build.c +1 -0
index 46eddb8..95e0c65 100644
@@ -169,6 +169,7 @@ static void acpi_get_pm_info(AcpiPmInfo *pm)
     Object *obj = NULL;
     QObject *o;
 
+    pm->cpu_hp_io_base = 0;
     pm->pcihp_io_base = 0;
     pm->pcihp_io_len = 0;
     if (piix) {