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().
Fixes: 18c22d7112 (qdev-properties: Add a new macro with bitmask check for uint64_t property)
Cc: qemu-stable@nongnu.org
Signed-off-by: Zesen Liu <ftyghome@gmail.com>
Message-ID: <20251217-qdev-fix-v1-1-bd33ea463220@gmail.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
[Add Fixes: and Cc:]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
parent
7154e4df40
commit
00829ae384
1 changed files with 3 additions and 1 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue