qemu/hw-core-machine-smp-Initialize-caches_bitmap-before-.patch

48 lines
1.7 KiB
Diff
Raw Normal View History

From 4f12da5913773e6beba7edd530d85ebe58889c28 Mon Sep 17 00:00:00 2001
From: huangchengfei <huangchengfei3@huawei.com>
Date: Fri, 7 Mar 2025 15:51:01 +0800
Subject: [PATCH] hw/core/machine-smp: Initialize caches_bitmap before reading
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
mainline inclusion
from mainline-master
commit 9c2644948c71db61a04f22398cde72224a98267a
category: feature
Reference: https://github.com/qemu/qemu/commit/9c2644948c71db61a04f22398cde72224a98267a
commit 9c2644948c71db61a04f22398cde72224a98267a upstream
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: 4e88e7e ("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>
---
hw/core/machine-smp.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/hw/core/machine-smp.c b/hw/core/machine-smp.c
index 9d1aa3afb3..a421a394d4 100644
--- a/hw/core/machine-smp.c
+++ b/hw/core/machine-smp.c
@@ -201,6 +201,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)) {
--
2.41.0.windows.1