From: Eric Blake <eblake@redhat.com>
To: Eduardo Habkost <ehabkost@redhat.com>, qemu-devel@nongnu.org
Cc: "Thomas Huth" <thuth@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Cornelia Huck" <cohuck@redhat.com>,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2 1/3] qom: Don't keep error value between object_property_parse() calls
Date: Wed, 9 Jan 2019 20:43:13 -0600 [thread overview]
Message-ID: <139331a6-f588-81eb-0104-83c814d74c7f@redhat.com> (raw)
In-Reply-To: <20190110020259.8492-2-ehabkost@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 2229 bytes --]
On 1/9/19 8:02 PM, Eduardo Habkost wrote:
> When handling errp==NULL at object_apply_global_props(), we are
> leaving the old error value in `err` after printing a warning.
> This makes QEMU crash if two global properties generate warnings:
>
> $ echo device_add rtl8139 | qemu-system-x86_64 -monitor stdio -global rtl8139.xxx=yyy -global rtl8139.xxx=zzz
> warning: can't apply global rtl8139.xxx=yyy: Property '.xxx' not found
> qemu-system-x86_64: util/error.c:57: error_setv: Assertion `*errp == NULL' failed.
> Aborted (core dumped)
>
> Fix that by making `err` go out of scope immediately after the
> warn_report_err() call.
>
> Fixes: 50545b2cc029 "qdev-props: call object_apply_global_props()"
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> qom/object.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/qom/object.c b/qom/object.c
> index aa6f3a2a71..4e5226ca12 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -372,7 +372,6 @@ static void object_post_init_with_type(Object *obj, TypeImpl *ti)
>
> void object_apply_global_props(Object *obj, const GPtrArray *props, Error **errp)
> {
> - Error *err = NULL;
Could also have been fixed by leaving this line at this scope,...
> int i;
>
> if (!props) {
> @@ -381,6 +380,7 @@ void object_apply_global_props(Object *obj, const GPtrArray *props, Error **errp
>
> for (i = 0; i < props->len; i++) {
> GlobalProperty *p = g_ptr_array_index(props, i);
> + Error *err = NULL;
>
> if (object_dynamic_cast(obj, p->driver) == NULL) {
> continue;
>
...and doing 'err = NULL;' after warn_report_err(). That is, it's not
the going out of scope that fixes it per se, but the fact that you
changed to resetting it to NULL on each loop invocation rather than
leaving it pointing at freed memory. Whether you set to NULL by a
tighter scope initializer or by an assignment doesn't matter, so no need
to respin since your way works.
Reviewed-by: Eric Blake <eblake@redhat.com>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2019-01-10 2:43 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-10 2:02 [Qemu-devel] [PATCH v2 0/3] Fix virtio-*(-non)-transitional crash on 2.6 machine-types Eduardo Habkost
2019-01-10 2:02 ` [Qemu-devel] [PATCH v2 1/3] qom: Don't keep error value between object_property_parse() calls Eduardo Habkost
2019-01-10 2:43 ` Eric Blake [this message]
2019-01-10 8:30 ` Marc-André Lureau
2019-01-10 10:42 ` Cornelia Huck
2019-01-10 2:02 ` [Qemu-devel] [PATCH v2 2/3] globals: Allow global properties to be optional Eduardo Habkost
2019-01-10 10:52 ` Cornelia Huck
2019-01-10 2:02 ` [Qemu-devel] [PATCH v2 3/3] virtio: Make disable-legacy/disable-modern compat properties optional Eduardo Habkost
2019-01-10 8:35 ` Marc-André Lureau
2019-01-10 11:15 ` Dr. David Alan Gilbert
2019-01-10 13:31 ` Eduardo Habkost
2019-01-10 14:12 ` Michael S. Tsirkin
2019-01-10 15:01 ` Dr. David Alan Gilbert
2019-01-10 18:07 ` Eduardo Habkost
2019-01-10 21:06 ` Marc-André Lureau
2019-01-11 8:22 ` Cornelia Huck
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=139331a6-f588-81eb-0104-83c814d74c7f@redhat.com \
--to=eblake@redhat.com \
--cc=cohuck@redhat.com \
--cc=dgilbert@redhat.com \
--cc=ehabkost@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=thuth@redhat.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).