[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-stable] [PATCH 25/40] qom: Do not reuse errp after a possible erro
From: |
Michael Roth |
Subject: |
[Qemu-stable] [PATCH 25/40] qom: Do not reuse errp after a possible error |
Date: |
Wed, 21 Oct 2015 12:51:55 -0500 |
From: Markus Armbruster <address@hidden>
The argument for an Error **errp parameter must point to a null
pointer. If it doesn't, and an error happens, error_set() fails its
assertion.
Instead of
foo(foos, errp);
bar(bars, errp);
you need to do something like
Error *err = NULL;
foo(foos, &err);
if (err) {
error_propagate(errp, err);
goto out;
}
bar(bars, errp);
out:
Screwed up in commit 0e55884 (v1.3.0): property_get_bool().
Screwed up in commit 1f21772 (v2.1.0): object_property_get_enum() and
object_property_get_uint16List().
Screwed up in commit a8e3fbe (v2.4.0): property_get_enum(),
property_set_enum().
Found by inspection, no actual crashes observed.
Fix them up.
Cc: Anthony Liguori <address@hidden>
Cc: Hu Tao <address@hidden>
Cc: Daniel P. Berrange <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Daniel P. Berrange <address@hidden>
Cc: address@hidden
Signed-off-by: Andreas Färber <address@hidden>
(cherry picked from commit 4715d42efe8632b0f9d2594a80e917de45e4ef88)
Signed-off-by: Michael Roth <address@hidden>
---
qom/object.c | 41 +++++++++++++++++++++++++++++++++++------
1 file changed, 35 insertions(+), 6 deletions(-)
diff --git a/qom/object.c b/qom/object.c
index eea8edf..c9aedd0 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -1079,6 +1079,7 @@ typedef struct EnumProperty {
int object_property_get_enum(Object *obj, const char *name,
const char *typename, Error **errp)
{
+ Error *err = NULL;
StringOutputVisitor *sov;
StringInputVisitor *siv;
char *str;
@@ -1100,7 +1101,12 @@ int object_property_get_enum(Object *obj, const char
*name,
enumprop = prop->opaque;
sov = string_output_visitor_new(false);
- object_property_get(obj, string_output_get_visitor(sov), name, errp);
+ object_property_get(obj, string_output_get_visitor(sov), name, &err);
+ if (err) {
+ error_propagate(errp, err);
+ string_output_visitor_cleanup(sov);
+ return 0;
+ }
str = string_output_get_string(sov);
siv = string_input_visitor_new(str);
string_output_visitor_cleanup(sov);
@@ -1116,21 +1122,27 @@ int object_property_get_enum(Object *obj, const char
*name,
void object_property_get_uint16List(Object *obj, const char *name,
uint16List **list, Error **errp)
{
+ Error *err = NULL;
StringOutputVisitor *ov;
StringInputVisitor *iv;
char *str;
ov = string_output_visitor_new(false);
object_property_get(obj, string_output_get_visitor(ov),
- name, errp);
+ name, &err);
+ if (err) {
+ error_propagate(errp, err);
+ goto out;
+ }
str = string_output_get_string(ov);
iv = string_input_visitor_new(str);
visit_type_uint16List(string_input_get_visitor(iv),
list, NULL, errp);
g_free(str);
- string_output_visitor_cleanup(ov);
string_input_visitor_cleanup(iv);
+out:
+ string_output_visitor_cleanup(ov);
}
void object_property_parse(Object *obj, const char *string,
@@ -1646,8 +1658,14 @@ static void property_get_bool(Object *obj, Visitor *v,
void *opaque,
{
BoolProperty *prop = opaque;
bool value;
+ Error *err = NULL;
+
+ value = prop->get(obj, &err);
+ if (err) {
+ error_propagate(errp, err);
+ return;
+ }
- value = prop->get(obj, errp);
visit_type_bool(v, &value, name, errp);
}
@@ -1701,8 +1719,14 @@ static void property_get_enum(Object *obj, Visitor *v,
void *opaque,
{
EnumProperty *prop = opaque;
int value;
+ Error *err = NULL;
+
+ value = prop->get(obj, &err);
+ if (err) {
+ error_propagate(errp, err);
+ return;
+ }
- value = prop->get(obj, errp);
visit_type_enum(v, &value, prop->strings, NULL, name, errp);
}
@@ -1711,8 +1735,13 @@ static void property_set_enum(Object *obj, Visitor *v,
void *opaque,
{
EnumProperty *prop = opaque;
int value;
+ Error *err = NULL;
- visit_type_enum(v, &value, prop->strings, NULL, name, errp);
+ visit_type_enum(v, &value, prop->strings, NULL, name, &err);
+ if (err) {
+ error_propagate(errp, err);
+ return;
+ }
prop->set(obj, value, errp);
}
--
1.9.1
- [Qemu-stable] [PATCH 17/40] target-arm: Share all common TCG temporaries, (continued)
- [Qemu-stable] [PATCH 17/40] target-arm: Share all common TCG temporaries, Michael Roth, 2015/10/21
- [Qemu-stable] [PATCH 16/40] virtio dataplane: adapt dataplane for virtio Version 1, Michael Roth, 2015/10/21
- [Qemu-stable] [PATCH 18/40] qcow2: Make size_to_clusters() return uint64_t, Michael Roth, 2015/10/21
- [Qemu-stable] [PATCH 01/40] scsi-disk: Fix assertion failure on WRITE SAME, Michael Roth, 2015/10/21
- [Qemu-stable] [PATCH 23/40] slirp: Fix non blocking connect for w32, Michael Roth, 2015/10/21
- [Qemu-stable] [PATCH 24/40] ide: unify io_buffer_offset increments, Michael Roth, 2015/10/21
- [Qemu-stable] [PATCH 22/40] nbd: release exp->blk after all clients are closed, Michael Roth, 2015/10/21
- [Qemu-stable] [PATCH 19/40] ide: fix ATAPI command permissions, Michael Roth, 2015/10/21
- [Qemu-stable] [PATCH 20/40] gtk: use setlocale() for LC_MESSAGES only, Michael Roth, 2015/10/21
- [Qemu-stable] [PATCH 21/40] spapr_pci: fix device tree props for MSI/MSI-X, Michael Roth, 2015/10/21
- [Qemu-stable] [PATCH 25/40] qom: Do not reuse errp after a possible error,
Michael Roth <=
- [Qemu-stable] [PATCH 26/40] qom: Fix invalid error check in property_get_str(), Michael Roth, 2015/10/21
- [Qemu-stable] [PATCH 27/40] tcg/mips: Fix clobbering of qemu_ld inputs, Michael Roth, 2015/10/21
- [Qemu-stable] [PATCH 28/40] target-ppc: fix vcipher, vcipherlast, vncipherlast and vpermxor, Michael Roth, 2015/10/21
- [Qemu-stable] [PATCH 29/40] target-ppc: fix xscmpodp and xscmpudp decoding, Michael Roth, 2015/10/21
- [Qemu-stable] [PATCH 02/40] mirror: Fix coroutine reentrance, Michael Roth, 2015/10/21
- [Qemu-stable] [PATCH 31/40] virtio-net: unbreak self announcement and guest offloads after migration, Michael Roth, 2015/10/21
- [Qemu-stable] [PATCH 32/40] vmxnet3: Drop net_vmxnet3_info.can_receive, Michael Roth, 2015/10/21
- [Qemu-stable] [PATCH 30/40] virtio: avoid leading underscores for helpers, Michael Roth, 2015/10/21
- [Qemu-stable] [PATCH 35/40] Revert "qdev: Use qdev_get_device_class() for -device <type>, help", Michael Roth, 2015/10/21
- [Qemu-stable] [PATCH 33/40] qmp: Fix device-list-properties not to crash for abstract device, Michael Roth, 2015/10/21