[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 42/48] vl: fix leak of qdict_crumple return value
From: |
Paolo Bonzini |
Subject: |
[PULL 42/48] vl: fix leak of qdict_crumple return value |
Date: |
Thu, 8 Jul 2021 17:17:42 +0200 |
Coverity reports that qemu_parse_config_group is returning without
unrefing the "crumpled" dictionary in case its top level item is a
list. But actually the contract with qemu_record_config_group is
the same as for qemu_parse_config_group itself: if those function
need to stash the dictionary they get, they have to take a reference
themselves (currently this is never the case for either function).
Therefore, just add an unconditional qobject_unref(crumpled) to
qemu_parse_config_group.
Reported-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
softmmu/vl.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/softmmu/vl.c b/softmmu/vl.c
index 2004d57108..4df1496101 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -2193,12 +2193,17 @@ static void qemu_parse_config_group(const char *group,
QDict *qdict,
if (!crumpled) {
return;
}
- if (qobject_type(crumpled) != QTYPE_QDICT) {
- assert(qobject_type(crumpled) == QTYPE_QLIST);
+ switch (qobject_type(crumpled)) {
+ case QTYPE_QDICT:
+ qemu_record_config_group(group, qobject_to(QDict, crumpled), false,
errp);
+ break;
+ case QTYPE_QLIST:
error_setg(errp, "Lists cannot be at top level of a configuration
section");
- return;
+ break;
+ default:
+ g_assert_not_reached();
}
- qemu_record_config_group(group, qobject_to(QDict, crumpled), false, errp);
+ qobject_unref(crumpled);
}
static void qemu_read_default_config_file(Error **errp)
--
2.31.1
- [PULL 40/48] target/i386: Added DR6 and DR7 consistency checks, (continued)
- [PULL 40/48] target/i386: Added DR6 and DR7 consistency checks, Paolo Bonzini, 2021/07/08
- [PULL 36/48] monitor/usb: register 'info usbhost' dynamically, Paolo Bonzini, 2021/07/08
- [PULL 38/48] monitor/tcg: move tcg hmp commands to accel/tcg, register them dynamically, Paolo Bonzini, 2021/07/08
- [PULL 45/48] hw/arm: add dependency on OR_IRQ for XLNX_VERSAL, Paolo Bonzini, 2021/07/08
- [PULL 48/48] configure: allow the selection of alternate config in the build, Paolo Bonzini, 2021/07/08
- [PULL 31/48] accel: build qtest modular, Paolo Bonzini, 2021/07/08
- [PULL 41/48] target/i386: fix exceptions for MOV to DR, Paolo Bonzini, 2021/07/08
- [PULL 43/48] meson: switch function tests from compilation to linking, Paolo Bonzini, 2021/07/08
- [PULL 44/48] meson: Introduce target-specific Kconfig, Paolo Bonzini, 2021/07/08
- [PULL 47/48] configs: rename default-configs to configs and reorganise, Paolo Bonzini, 2021/07/08
- [PULL 42/48] vl: fix leak of qdict_crumple return value,
Paolo Bonzini <=
- [PULL 46/48] hw/arm: move CONFIG_V7M out of default-devices, Paolo Bonzini, 2021/07/08
- Re: [PULL 00/48] Misc patches for QEMU 6.1 soft freeze, Peter Maydell, 2021/07/09