summary refs log tree commit diff stats
path: root/hw/core/machine-smp.c
diff options
context:
space:
mode:
authorZhao Liu <zhao1.liu@intel.com>2024-11-10 23:09:00 +0800
committerPaolo Bonzini <pbonzini@redhat.com>2024-11-19 18:38:25 +0100
commit9c2644948c71db61a04f22398cde72224a98267a (patch)
treef5dd869aad926adf3f39bba163b11302e3fa5a5c /hw/core/machine-smp.c
parent19d542cc0bce0b3641e80444374f9ffd8294a15b (diff)
downloadfocaccia-qemu-9c2644948c71db61a04f22398cde72224a98267a.tar.gz
focaccia-qemu-9c2644948c71db61a04f22398cde72224a98267a.zip
hw/core/machine-smp: Initialize caches_bitmap before reading
The caches_bitmap is defined in machine_parse_smp_cache(), but it was
not initialized.

Initialize caches_bitmap by clearing all its bits to zero.

Resolves: Coverity CID 1565389
Fixes: 4e88e7e3403d ("qapi/qom: Define cache enumeration and properties for machine")
Reported-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Link: https://lore.kernel.org/r/20241110150901.130647-2-zhao1.liu@intel.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw/core/machine-smp.c')
-rw-r--r--hw/core/machine-smp.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/hw/core/machine-smp.c b/hw/core/machine-smp.c
index 640b2114b4..b87637c78f 100644
--- a/hw/core/machine-smp.c
+++ b/hw/core/machine-smp.c
@@ -290,6 +290,7 @@ bool machine_parse_smp_cache(MachineState *ms,
     const SmpCachePropertiesList *node;
     DECLARE_BITMAP(caches_bitmap, CACHE_LEVEL_AND_TYPE__MAX);
 
+    bitmap_zero(caches_bitmap, CACHE_LEVEL_AND_TYPE__MAX);
     for (node = caches; node; node = node->next) {
         /* Prohibit users from repeating settings. */
         if (test_bit(node->value->cache, caches_bitmap)) {