From: "Andreas Färber" <afaerber@suse.de>
To: arei.gonglei@huawei.com, qemu-devel@nongnu.org
Cc: luonengjun@huawei.com, weidong.huang@huawei.com,
armbru@redhat.com, pbonzini@redhat.com
Subject: Re: [Qemu-devel] [PATCH 1/2] qom: add error handler for object_property_print()
Date: Tue, 23 Sep 2014 15:16:09 +0200 [thread overview]
Message-ID: <54217299.7000408@suse.de> (raw)
In-Reply-To: <1411442750-6992-2-git-send-email-arei.gonglei@huawei.com>
Hi,
Am 23.09.2014 um 05:25 schrieb arei.gonglei@huawei.com:
> From: Gonglei <arei.gonglei@huawei.com>
>
> Avoid the caller of object_property_print() leaking string
> argument's memory, such as qdev_print_props() when
> encounter errors.
>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
> ---
> qom/object.c | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/qom/object.c b/qom/object.c
> index da0919a..74779e6 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -1010,11 +1010,19 @@ char *object_property_print(Object *obj, const char *name, bool human,
> Error **errp)
> {
> StringOutputVisitor *mo;
> - char *string;
> + char *string = NULL;
> + Error *local_err = NULL;
>
> mo = string_output_visitor_new(human);
> - object_property_get(obj, string_output_get_visitor(mo), name, errp);
> + object_property_get(obj, string_output_get_visitor(mo), name, &local_err);
> + if (local_err) {
> + error_propagate(errp, local_err);
> + goto fail;
> + }
> +
> string = string_output_get_string(mo);
> +
> +fail:
Permission to rename the label to "out" as in 2/2?
Series looks good otherwise.
Regards,
Andreas
> string_output_visitor_cleanup(mo);
> return string;
> }
>
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
next prev parent reply other threads:[~2014-09-23 13:16 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-23 3:25 [Qemu-devel] [PATCH 0/2] qom: add error handler for security arei.gonglei
2014-09-23 3:25 ` [Qemu-devel] [PATCH 1/2] qom: add error handler for object_property_print() arei.gonglei
2014-09-23 13:16 ` Andreas Färber [this message]
2014-09-23 13:25 ` Gonglei (Arei)
2014-09-23 3:25 ` [Qemu-devel] [PATCH 2/2] qom: add error handler for object alias property arei.gonglei
2014-09-23 3:51 ` [Qemu-devel] [PATCH 0/2] qom: add error handler for security Eric Blake
2014-09-23 3:56 ` Gonglei (Arei)
2014-09-23 13:11 ` Paolo Bonzini
2014-09-23 13:21 ` Gonglei (Arei)
2014-09-23 13:22 ` Paolo Bonzini
2014-09-23 13:24 ` Gonglei (Arei)
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=54217299.7000408@suse.de \
--to=afaerber@suse.de \
--cc=arei.gonglei@huawei.com \
--cc=armbru@redhat.com \
--cc=luonengjun@huawei.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=weidong.huang@huawei.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).