[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 16/16] target-i386: cpu: fix invalid use of error_is
From: |
Igor Mammedov |
Subject: |
[Qemu-devel] [PATCH 16/16] target-i386: cpu: fix invalid use of error_is_set(errp) if errp == NULL |
Date: |
Wed, 27 Nov 2013 23:28:56 +0100 |
in generic case errp may be NULL and if an Error gets raised in visitor
but not set to *errp for the lack of pointer, value might be uninitialized:
object_property_parse(obj, "invalid value", "foo", NULL);
and accessed futher in property setter leading to incorrect property
value of object instance.
So we cannot rely on error_is_set(errp) but must use a local variable
to detect error condition and return earlier.
Signed-off-by: Igor Mammedov <address@hidden>
---
target-i386/cpu.c | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 2220eae..7064818 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1110,10 +1110,12 @@ static void x86_cpuid_version_set_family(Object *obj,
Visitor *v, void *opaque,
CPUX86State *env = &cpu->env;
const int64_t min = 0;
const int64_t max = 0xff + 0xf;
+ Error *err = NULL;
int64_t value;
- visit_type_int(v, &value, name, errp);
- if (error_is_set(errp)) {
+ visit_type_int(v, &value, name, &err);
+ if (err) {
+ error_propagate(errp, err);
return;
}
if (value < min || value > max) {
@@ -1155,10 +1157,12 @@ static void x86_cpuid_version_set_model(Object *obj,
Visitor *v, void *opaque,
CPUX86State *env = &cpu->env;
const int64_t min = 0;
const int64_t max = 0xff;
+ Error *err = NULL;
int64_t value;
- visit_type_int(v, &value, name, errp);
- if (error_is_set(errp)) {
+ visit_type_int(v, &value, name, &err);
+ if (err) {
+ error_propagate(errp, err);
return;
}
if (value < min || value > max) {
@@ -1197,10 +1201,12 @@ static void x86_cpuid_version_set_stepping(Object *obj,
Visitor *v,
CPUX86State *env = &cpu->env;
const int64_t min = 0;
const int64_t max = 0xf;
+ Error *err = NULL;
int64_t value;
- visit_type_int(v, &value, name, errp);
- if (error_is_set(errp)) {
+ visit_type_int(v, &value, name, &err);
+ if (err) {
+ error_propagate(errp, err);
return;
}
if (value < min || value > max) {
@@ -1337,10 +1343,12 @@ static void x86_cpuid_set_tsc_freq(Object *obj, Visitor
*v, void *opaque,
X86CPU *cpu = X86_CPU(obj);
const int64_t min = 0;
const int64_t max = INT64_MAX;
+ Error *err = NULL;
int64_t value;
- visit_type_int(v, &value, name, errp);
- if (error_is_set(errp)) {
+ visit_type_int(v, &value, name, &err);
+ if (err) {
+ error_propagate(errp, err);
return;
}
if (value < min || value > max) {
--
1.8.3.1
- [Qemu-devel] [PATCH 04/16] target-i386: cpu: convert 'xlevel' to static property, (continued)
- [Qemu-devel] [PATCH 04/16] target-i386: cpu: convert 'xlevel' to static property, Igor Mammedov, 2013/11/27
- [Qemu-devel] [PATCH 06/16] target-i386: cpu: convert 'model' to static property, Igor Mammedov, 2013/11/27
- [Qemu-devel] [PATCH 07/16] target-i386: cpu: convert 'stepping' to static property, Igor Mammedov, 2013/11/27
- [Qemu-devel] [PATCH 08/16] target-i386: cpu: convert 'vendor' to static property, Igor Mammedov, 2013/11/27
- [Qemu-devel] [PATCH 11/16] target-i386: set [+-]feature using static properties, Igor Mammedov, 2013/11/27
- [Qemu-devel] [PATCH 09/16] target-i386: cpu: convert 'model-id' to static property, Igor Mammedov, 2013/11/27
- [Qemu-devel] [PATCH 10/16] target-i386: cpu: convert 'tsc-frequency' to static property, Igor Mammedov, 2013/11/27
- [Qemu-devel] [PATCH 13/16] target-i386: use static properties in check_features_against_host() to print CPUID feature names, Igor Mammedov, 2013/11/27
- [Qemu-devel] [PATCH 14/16] target-i386: use static properties to list CPUID features, Igor Mammedov, 2013/11/27
- [Qemu-devel] [PATCH 12/16] qdev: introduce qdev_prop_find_bit(), Igor Mammedov, 2013/11/27
- [Qemu-devel] [PATCH 16/16] target-i386: cpu: fix invalid use of error_is_set(errp) if errp == NULL,
Igor Mammedov <=
- [Qemu-devel] [PATCH 15/16] target-i386: remove unused *_feature_name arrays, Igor Mammedov, 2013/11/27