qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>,
	qemu-devel@nongnu.org
Cc: kwolf@redhat.com, pkrempa@redhat.com, stefanha@gmail.com,
	jcody@redhat.com, deepakcs@redhat.com,
	bharata@linux.vnet.ibm.com, rtalur@redhat.com
Subject: Re: [Qemu-devel] [PATCH 3/4] block/gluster: using new qapi schema
Date: Thu, 12 Nov 2015 14:37:41 -0700	[thread overview]
Message-ID: <564506A5.8070705@redhat.com> (raw)
In-Reply-To: <1447323728-2427-4-git-send-email-prasanna.kalever@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 2539 bytes --]

On 11/12/2015 03:22 AM, Prasanna Kumar Kalever wrote:
> this patch adds GlusterConf to qapi/block-core.json
> 
> Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
> ---
>  block/gluster.c      | 104 +++++++++++++++++++++++++--------------------------
>  qapi/block-core.json |  60 +++++++++++++++++++++++++++--
>  2 files changed, 109 insertions(+), 55 deletions(-)

One more comment:

> -static int qemu_gluster_parseuri(GlusterConf *gconf, const char *filename)
> +static int qemu_gluster_parseuri(BlockdevOptionsGluster **pgconf,
> +                                 const char *filename)
>  {
> +    BlockdevOptionsGluster *gconf;
>      URI *uri;
>      QueryParams *qp = NULL;
>      bool is_unix = false;
> @@ -155,20 +141,24 @@ static int qemu_gluster_parseuri(GlusterConf *gconf, const char *filename)
>          return -EINVAL;

If we hit this early return, then *pgconf was never assigned...


> +static struct glfs *qemu_gluster_init(BlockdevOptionsGluster **pgconf,
> +                                      const char *filename, Error **errp)
>  {
> -    struct glfs *glfs = NULL;
> +    struct glfs *glfs;
>      int ret;
>      int old_errno;
> +    BlockdevOptionsGluster *gconf;

but here, gconf is uninitialized,

>  
> -    ret = qemu_gluster_parseuri(gconf, filename);
> +    ret = qemu_gluster_parseuri(&gconf, filename);
>      if (ret < 0) {
>          error_setg(errp, "Usage: file=gluster[+transport]://[host[:port]]/"
>                           "volume/path[?socket=...]");

which means we can goto out with it uninitialized...

> @@ -224,8 +225,9 @@ static struct glfs *qemu_gluster_init(GlusterConf *gconf, const char *filename,
>          goto out;
>      }
>  
> -    ret = glfs_set_volfile_server(glfs, gconf->transport, gconf->host,
> -            gconf->port);
> +    ret = glfs_set_volfile_server(glfs,
> +                                  GlusterTransport_lookup[gconf->server->transport],
> +                                  gconf->server->host, gconf->server->port);
>      if (ret < 0) {
>          goto out;
>      }

...vs. here where we can goto out with it initialized.

So whatever solution you use to plug the leak must be careful to not
free uninitialized memory.  Easiest solution - initialize gconf to NULL
before qemu_gluster_parseuri (or else go back to a *gconf parameter
rather than **pgconf).

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

  parent reply	other threads:[~2015-11-12 21:37 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-12 10:22 [Qemu-devel] [PATCH 0/4] block/gluster: add support for multiple gluster servers Prasanna Kumar Kalever
2015-11-12 10:22 ` [Qemu-devel] [PATCH 1/4] block/gluster: rename [server, volname, image] -> [host, volume, path] Prasanna Kumar Kalever
2015-11-12 20:28   ` Eric Blake
2015-11-12 10:22 ` [Qemu-devel] [PATCH 2/4] block/gluster: code cleanup Prasanna Kumar Kalever
2015-11-12 10:22 ` [Qemu-devel] [PATCH 3/4] block/gluster: using new qapi schema Prasanna Kumar Kalever
2015-11-12 20:00   ` Jeff Cody
2015-11-12 21:16   ` Eric Blake
2015-11-12 21:37   ` Eric Blake [this message]
2015-11-12 22:44   ` Eric Blake
2015-11-13  8:04   ` Markus Armbruster
2015-11-12 10:22 ` [Qemu-devel] [PATCH 4/4] block/gluster: add support for multiple gluster servers Prasanna Kumar Kalever
2015-11-12 20:00   ` Jeff Cody
2015-11-12 22:36   ` Eric Blake
2016-02-04 13:22     ` Kevin Wolf
2016-02-05 13:17       ` Prasanna Kumar Kalever
2016-03-23 12:16         ` Prasanna Kalever
2016-03-23 12:22           ` Prasanna Kalever
2015-11-12 22:54 ` [Qemu-devel] [PATCH 0/4] " Eric Blake

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=564506A5.8070705@redhat.com \
    --to=eblake@redhat.com \
    --cc=bharata@linux.vnet.ibm.com \
    --cc=deepakcs@redhat.com \
    --cc=jcody@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=pkrempa@redhat.com \
    --cc=prasanna.kalever@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rtalur@redhat.com \
    --cc=stefanha@gmail.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).