Skip to contentSkip to conversation

qdev: fix error handling in set_uint64_checkmask

PATCH In review Zesen Liu 2 participants 3 messages Dec 17, 2025

lore
Share & tools
lore

Zesen Liu

author
#0 lore raw

PATCH 1/1 qdev: fix error handling in set_uint64_checkmask

When specifying lbr_fmt=VALUE in cpu options with an invalid VALUE, error_setg() gets triggered twice, causing an assertion failure in error_setv() which requires *errp to be NULL, preventing meaningful error messages from being displayed.

Fix this by checking visit_type_uint64()'s return value and returning early on failure, consistent with other property setters like set_string().

---
 hw/core/qdev-properties.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
hw/core/qdev-properties.c +3 -1
index 422a486969..0930d64252 100644
@@ -494,7 +494,9 @@ static void set_uint64_checkmask(Object *obj, Visitor *v, const char *name,
     const Property *prop = opaque;
     uint64_t *ptr = object_field_prop_ptr(obj, prop);
 
-    visit_type_uint64(v, name, ptr, errp);
+    if (!visit_type_uint64(v, name, ptr, errp)) {
+        return;
+    }
     if (*ptr & ~prop->bitmask) {
         error_setg(errp, "Property value for '%s' has bits outside mask '0x%" PRIx64 "'",
                    name, prop->bitmask);

---
base-commit: 7154e4df40468012fccb6687ecd2b288c56a4a2d
change-id: 20251217-qdev-fix-207bea2b8a14

Best regards,

Signature · 1 line
Zesen Liu <[email protected]>
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Zesen Liu

When specifying lbr_fmt=VALUE in cpu options with an invalid VALUE, error_setg() gets triggered twice, causing an assertion failure in error_setv() which requires *errp to be NULL, preventing meaningful error messages from being displayed.

Fix this by checking visit_type_uint64()'s return value and returning early on failure, consistent with other property setters like set_string().

Let's add

Fixes 18c22d7112a7 (qdev-properties: Add a new macro with bitmask check for uint64_t property)
Quoted 10 lines
---
 hw/core/qdev-properties.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
hw/core/qdev-properties.c +0 -0
index 422a486969..0930d64252 100644

hw/core/qdev-properties.c static void set_uint64_checkmask(Object *obj, Visitor *v, const char *name, · line 502

Quoted 10 lines
hw/core/qdev-properties.c +3 -1
@@ -494,7 +494,9 @@ static void set_uint64_checkmask(Object *obj, Visitor *v, const char *name,
     const Property *prop = opaque;
     uint64_t *ptr = object_field_prop_ptr(obj, prop);
 
-    visit_type_uint64(v, name, ptr, errp);
+    if (!visit_type_uint64(v, name, ptr, errp)) {
+        return;
+    }
     if (*ptr & ~prop->bitmask) {
         error_setg(errp, "Property value for '%s' has bits outside mask '0x%" PRIx64 "'",
                    name, prop->bitmask);

We haven't tagged rc4. I'll post a PR right away, so we have a chance to get this fix into 10.2.

author
#2 lore raw

Thanks for the review and for updating the tags. :)

Quoted 40 lines · Markus Armbruster
Quoted 4 lines · Zesen Liu

When specifying lbr_fmt=VALUE in cpu options with an invalid VALUE, error_setg() gets triggered twice, causing an assertion failure in error_setv() which requires *errp to be NULL, preventing meaningful error messages from being displayed.

Fix this by checking visit_type_uint64()'s return value and returning early on failure, consistent with other property setters like set_string().

Let's add

Fixes 18c22d7112a7 (qdev-properties: Add a new macro with bitmask check for uint64_t property)
Quoted 10 lines

---
hw/core/qdev-properties.c | 4 +++-

1 file changed, 3 insertions(+), 1 deletion(-)
hw/core/qdev-properties.c +0 -0
index 422a486969..0930d64252 100644

hw/core/qdev-properties.c static void set_uint64_checkmask(Object *obj, Visitor *v, const char *name, · line 502

Quoted 10 lines
hw/core/qdev-properties.c +3 -1
@@ -494,7 +494,9 @@ static void set_uint64_checkmask(Object *obj, Visitor *v, const char *name,
    const Property *prop = opaque;
    uint64_t *ptr = object_field_prop_ptr(obj, prop);
 
-    visit_type_uint64(v, name, ptr, errp);
+    if (!visit_type_uint64(v, name, ptr, errp)) {
+        return;
+    }
    if (*ptr & ~prop->bitmask) {
        error_setg(errp, "Property value for '%s' has bits outside mask '0x%" PRIx64 "'",
                   name, prop->bitmask);

We haven't tagged rc4. I'll post a PR right away, so we have a chance to get this fix into 10.2.