From: Greg Kurz <groug@kaod.org>
To: Igor Mammedov <imammedo@redhat.com>
Cc: qemu-devel@nongnu.org,
Peter Crosthwaite <crosthwaite.peter@gmail.com>,
Eduardo Habkost <ehabkost@redhat.com>,
David Hildenbrand <david@redhat.com>,
Cornelia Huck <cohuck@redhat.com>, Alexander Graf <agraf@suse.de>,
qemu-stable@nongnu.org, qemu-s390x@nongnu.org,
Paolo Bonzini <pbonzini@redhat.com>,
Richard Henderson <rth@twiddle.net>
Subject: Re: [Qemu-devel] [PATCH 2/3] hw/s390x: fix memory leak in s390_init_ipl_dev()
Date: Thu, 29 Mar 2018 11:39:41 +0200 [thread overview]
Message-ID: <20180329113941.6eebc57f@bahia.lan> (raw)
In-Reply-To: <20180329112721.6c7ee3f3@redhat.com>
On Thu, 29 Mar 2018 11:27:21 +0200
Igor Mammedov <imammedo@redhat.com> wrote:
> On Thu, 29 Mar 2018 11:10:06 +0200
> Greg Kurz <groug@kaod.org> wrote:
>
> > The string returned by object_property_get_str() is dynamically allocated.
> >
> > Fixes: 3c4e9baacf4d9
> > Signed-off-by: Greg Kurz <groug@kaod.org>
> > ---
> > hw/s390x/s390-virtio-ccw.c | 5 ++++-
> > 1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
> > index 864145a7c6f3..435f7c99e77c 100644
> > --- a/hw/s390x/s390-virtio-ccw.c
> > +++ b/hw/s390x/s390-virtio-ccw.c
> > @@ -246,6 +246,7 @@ static void s390_init_ipl_dev(const char *kernel_filename,
> > {
> > Object *new = object_new(TYPE_S390_IPL);
> > DeviceState *dev = DEVICE(new);
> > + char *netboot_fw_prop;
> >
> > if (kernel_filename) {
> > qdev_prop_set_string(dev, "kernel", kernel_filename);
> > @@ -256,9 +257,11 @@ static void s390_init_ipl_dev(const char *kernel_filename,
> > qdev_prop_set_string(dev, "cmdline", kernel_cmdline);
> > qdev_prop_set_string(dev, "firmware", firmware);
> > qdev_prop_set_bit(dev, "enforce_bios", enforce_bios);
> > - if (!strlen(object_property_get_str(new, "netboot_fw", &error_abort))) {
> > + netboot_fw_prop = object_property_get_str(new, "netboot_fw", &error_abort);
> > + if (!strlen(netboot_fw_prop)) {
> probably not really issue here but,
> is strlen really safe in case netboot_fw_prop == NULL?
>
You're right, object_property_get_str() can theoretically return NULL and
strlen() would crash... Not sure how this would happen though. Anyway, the
current code doesn't check if object_property_get_str() returns NULL so
if this needs to be fixed as well, let's do it in a followup patch.
> > qdev_prop_set_string(dev, "netboot_fw", netboot_fw);
> > }
> > + g_free(netboot_fw_prop);
> > object_property_add_child(qdev_get_machine(), TYPE_S390_IPL,
> > new, NULL);
> > object_unref(new);
> >
> >
>
next prev parent reply other threads:[~2018-03-29 9:40 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-29 9:09 [Qemu-devel] [PATCH 0/3] fix memory leaks when using object_property_get_str() Greg Kurz
2018-03-29 9:09 ` [Qemu-devel] [PATCH 1/3] exec: fix memory leak in find_max_supported_pagesize() Greg Kurz
2018-03-29 9:18 ` Cornelia Huck
2018-03-29 9:44 ` Greg Kurz
2018-03-29 11:47 ` [Qemu-devel] [qemu-s390x] " Thomas Huth
2018-04-03 2:06 ` [Qemu-devel] " Eduardo Habkost
2018-03-29 9:10 ` [Qemu-devel] [PATCH 2/3] hw/s390x: fix memory leak in s390_init_ipl_dev() Greg Kurz
2018-03-29 9:20 ` Cornelia Huck
2018-03-29 9:27 ` Igor Mammedov
2018-03-29 9:28 ` Cornelia Huck
2018-03-29 9:39 ` Greg Kurz [this message]
2018-03-29 10:31 ` Cornelia Huck
2018-03-29 11:49 ` [Qemu-devel] [qemu-s390x] " Thomas Huth
2018-03-29 11:50 ` Thomas Huth
2018-03-29 12:09 ` [Qemu-devel] " Cornelia Huck
2018-03-29 9:10 ` [Qemu-devel] [PATCH 3/3] sev/i386: fix memory leak in sev_guest_init() Greg Kurz
2018-03-29 9:24 ` Cornelia Huck
2018-03-29 10:27 ` Greg Kurz
2018-03-29 11:56 ` [Qemu-devel] [qemu-s390x] " Thomas Huth
2018-04-03 2:07 ` [Qemu-devel] " Eduardo Habkost
2018-03-31 6:39 ` [Qemu-devel] [PATCH 0/3] fix memory leaks when using object_property_get_str() no-reply
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=20180329113941.6eebc57f@bahia.lan \
--to=groug@kaod.org \
--cc=agraf@suse.de \
--cc=cohuck@redhat.com \
--cc=crosthwaite.peter@gmail.com \
--cc=david@redhat.com \
--cc=ehabkost@redhat.com \
--cc=imammedo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=qemu-stable@nongnu.org \
--cc=rth@twiddle.net \
/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).