* [PATCH] qdev: fix error handling in set_uint64_checkmask
@ 2025-12-17 3:59 Zesen Liu
2025-12-17 8:22 ` Markus Armbruster
0 siblings, 1 reply; 3+ messages in thread
From: Zesen Liu @ 2025-12-17 3:59 UTC (permalink / raw)
To: qemu-devel
Cc: Paolo Bonzini, Daniel P. Berrangé, Eduardo Habkost,
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().
Signed-off-by: Zesen Liu <ftyghome@gmail.com>
---
hw/core/qdev-properties.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index 422a486969..0930d64252 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -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,
--
Zesen Liu <ftyghome@gmail.com>
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] qdev: fix error handling in set_uint64_checkmask
2025-12-17 3:59 [PATCH] qdev: fix error handling in set_uint64_checkmask Zesen Liu
@ 2025-12-17 8:22 ` Markus Armbruster
2025-12-17 8:29 ` Zesen Liu
0 siblings, 1 reply; 3+ messages in thread
From: Markus Armbruster @ 2025-12-17 8:22 UTC (permalink / raw)
To: Zesen Liu
Cc: qemu-devel, Paolo Bonzini, Daniel P. Berrangé,
Eduardo Habkost
Zesen Liu <ftyghome@gmail.com> writes:
> 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)
Cc: qemu-stable@nongnu.org
> Signed-off-by: Zesen Liu <ftyghome@gmail.com>
> ---
> hw/core/qdev-properties.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
> index 422a486969..0930d64252 100644
> --- a/hw/core/qdev-properties.c
> +++ b/hw/core/qdev-properties.c
> @@ -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);
Reviewed-by: Markus Armbruster <armbru@redhat.com>
We haven't tagged rc4. I'll post a PR right away, so we have a chance
to get this fix into 10.2.
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] qdev: fix error handling in set_uint64_checkmask
2025-12-17 8:22 ` Markus Armbruster
@ 2025-12-17 8:29 ` Zesen Liu
0 siblings, 0 replies; 3+ messages in thread
From: Zesen Liu @ 2025-12-17 8:29 UTC (permalink / raw)
To: Markus Armbruster
Cc: qemu-devel, Paolo Bonzini, "Daniel P. Berrangé",
Eduardo Habkost
Thanks for the review and for updating the tags. :)
> On Dec 17, 2025, at 16:22, Markus Armbruster <armbru@redhat.com> wrote:
>
> Zesen Liu <ftyghome@gmail.com> writes:
>
>> 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)
> Cc: qemu-stable@nongnu.org
>
>> Signed-off-by: Zesen Liu <ftyghome@gmail.com>
>> ---
>> hw/core/qdev-properties.c | 4 +++-
>> 1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
>> index 422a486969..0930d64252 100644
>> --- a/hw/core/qdev-properties.c
>> +++ b/hw/core/qdev-properties.c
>> @@ -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);
>
> Reviewed-by: Markus Armbruster <armbru@redhat.com>
>
> We haven't tagged rc4. I'll post a PR right away, so we have a chance
> to get this fix into 10.2.
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-12-17 9:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-17 3:59 [PATCH] qdev: fix error handling in set_uint64_checkmask Zesen Liu
2025-12-17 8:22 ` Markus Armbruster
2025-12-17 8:29 ` Zesen Liu
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.