From: Cornelia Huck <cohuck@redhat.com>
To: Greg Kurz <groug@kaod.org>
Cc: qemu-devel@nongnu.org,
Alex Williamson <alex.williamson@redhat.com>,
qemu-s390x@nongnu.org, qemu-stable@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2 1/2] vfio-ccw: fix memory leaks in vfio_ccw_realize()
Date: Mon, 9 Apr 2018 10:00:01 +0200 [thread overview]
Message-ID: <20180409100001.2ef30abb.cohuck@redhat.com> (raw)
In-Reply-To: <152311222681.203086.8874800175539040298.stgit@bahia>
On Sat, 07 Apr 2018 16:43:46 +0200
Greg Kurz <groug@kaod.org> wrote:
> If the subchannel is already attached or if vfio_get_device() fails, the
> code jumps to the 'out_device_err' label and doesn't free the string it
> has just allocated.
>
> The code should be reworked so that vcdev->vdev.name only gets set when
> the device has been attached, and freed when it is about to be detached.
> This could be achieved with the addition of a vfio_ccw_get_device()
> function that would be the counterpart of vfio_put_device(). But this is
> a more elaborate cleanup that should be done in a follow-up. For now,
> let's just add calls to g_free() on the buggy error paths.
>
> Signed-off-by: Greg Kurz <groug@kaod.org>
> ---
> hw/vfio/ccw.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c
> index 4e5855741a64..fe34b507699f 100644
> --- a/hw/vfio/ccw.c
> +++ b/hw/vfio/ccw.c
> @@ -357,11 +357,13 @@ static void vfio_ccw_realize(DeviceState *dev, Error **errp)
> if (strcmp(vbasedev->name, vcdev->vdev.name) == 0) {
> error_setg(&err, "vfio: subchannel %s has already been attached",
> vcdev->vdev.name);
> + g_free(vcdev->vdev.name);
> goto out_device_err;
> }
> }
>
> if (vfio_get_device(group, cdev->mdevid, &vcdev->vdev, &err)) {
> + g_free(vcdev->vdev.name);
> goto out_device_err;
> }
>
>
Thanks, applied to s390-fixes.
next prev parent reply other threads:[~2018-04-09 8:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-07 14:43 [Qemu-devel] [PATCH v2 0/2] vfio-ccw: fix memory leak + cleanup Greg Kurz
2018-04-07 14:43 ` [Qemu-devel] [PATCH v2 1/2] vfio-ccw: fix memory leaks in vfio_ccw_realize() Greg Kurz
2018-04-09 8:00 ` Cornelia Huck [this message]
2018-04-07 14:44 ` [Qemu-devel] [PATCH v2 2/2] vfio-ccw: introduce vfio_ccw_get_device() Greg Kurz
2018-04-09 9:01 ` 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=20180409100001.2ef30abb.cohuck@redhat.com \
--to=cohuck@redhat.com \
--cc=alex.williamson@redhat.com \
--cc=groug@kaod.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=qemu-stable@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 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).