From c0b6774d500d9a31da766213ebd8fd1bfed35b8f Mon Sep 17 00:00:00 2001 From: Jiri Denemark Date: Wed, 27 Nov 2024 08:34:52 +0100 Subject: [PATCH] cpu: Check blockers in virCPUCompareUnusable only if they exist virCPUCompareUnusable can be called with blockers == NULL in case the CPU model itself is usable (i.e., QEMU reports an empty list of blockers), but the CPU definition contains some additional features which have to be checked. Fixes: v10.8.0-129-g5f8abbb7d0 Reported-by: Han Han Signed-off-by: Jiri Denemark Tested-by: Han Han Reviewed-by: Peter Krempa --- src/cpu/cpu.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c index ef515744ba..77afb7e9b3 100644 --- a/src/cpu/cpu.c +++ b/src/cpu/cpu.c @@ -201,11 +201,13 @@ virCPUCompareUnusable(virArch arch, char **blocker; size_t i; - for (blocker = blockers; *blocker; blocker++) { - if (!(feat = virCPUDefFindFeature(cpu, *blocker)) || - feat->policy != VIR_CPU_FEATURE_DISABLE) { - virBufferAddStr(&features, *blocker); - virBufferAddLit(&features, ", "); + if (blockers) { + for (blocker = blockers; *blocker; blocker++) { + if (!(feat = virCPUDefFindFeature(cpu, *blocker)) || + feat->policy != VIR_CPU_FEATURE_DISABLE) { + virBufferAddStr(&features, *blocker); + virBufferAddLit(&features, ", "); + } } }