All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: Zesen Liu <ftyghome@gmail.com>
Cc: qemu-devel@nongnu.org, "Paolo Bonzini" <pbonzini@redhat.com>,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	"Eduardo Habkost" <eduardo@habkost.net>
Subject: Re: [PATCH] qdev: fix error handling in set_uint64_checkmask
Date: Wed, 17 Dec 2025 09:22:48 +0100	[thread overview]
Message-ID: <877bulo6uf.fsf@pond.sub.org> (raw)
In-Reply-To: <20251217-qdev-fix-v1-1-bd33ea463220@gmail.com> (Zesen Liu's message of "Wed, 17 Dec 2025 11:59:52 +0800")

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.



  reply	other threads:[~2025-12-17  8:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-17  3:59 [PATCH] qdev: fix error handling in set_uint64_checkmask Zesen Liu
2025-12-17  8:22 ` Markus Armbruster [this message]
2025-12-17  8:29   ` Zesen Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877bulo6uf.fsf@pond.sub.org \
    --to=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=eduardo@habkost.net \
    --cc=ftyghome@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.