diff mbox series

[PATCH-for-6.1?,v2,3/3] hw/core: fix error checkig in smp_parse

Message ID 20210813112608.1452541-4-philmd@redhat.com
State New
Headers show
Series hw/core: fix error checkig in smp_parse | expand

Commit Message

Philippe Mathieu-Daudé Aug. 13, 2021, 11:26 a.m. UTC
From: Daniel P. Berrangé <berrange@redhat.com>

The machine_set_smp() mistakenly checks 'errp' not '*errp',
and so thinks there is an error every single time it runs.
This causes it to jump to the end of the method, skipping
the max CPUs checks. The caller meanwhile sees no error
and so carries on execution. The result of all this is:

 $ qemu-system-x86_64 -smp -1
 qemu-system-x86_64: GLib: ../glib/gmem.c:142: failed to allocate 481036337048 bytes

instead of

 $ qemu-system-x86_64 -smp -1
 qemu-system-x86_64: Invalid SMP CPUs -1. The max CPUs supported by machine 'pc-i440fx-6.1' is 255

This is a regression from

  commit fe68090e8fbd6e831aaf3fc3bb0459c5cccf14cf
  Author: Paolo Bonzini <pbonzini@redhat.com>
  Date:   Thu May 13 09:03:48 2021 -0400

    machine: add smp compound property

Closes: https://gitlab.com/qemu-project/qemu/-/issues/524
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-Id: <20210812175353.4128471-1-berrange@redhat.com>
[PMD: Check MachineClass::smp_parse() returned value]
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 hw/core/machine.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/hw/core/machine.c b/hw/core/machine.c
index 159c6b098e2..29edf655140 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -834,8 +834,7 @@  static void machine_set_smp(Object *obj, Visitor *v, const char *name,
         return;
     }
 
-    mc->smp_parse(ms, config, errp);
-    if (errp) {
+    if (mc->smp_parse(ms, config, errp)) {
         goto out_free;
     }