From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>,
Xen-devel <xen-devel@lists.xen.org>
Cc: Ian Jackson <Ian.Jackson@eu.citrix.com>,
Ian Campbell <Ian.Campbell@citrix.com>
Subject: Re: [PATCH 3/4] tools/libxl: Fix libxl__device_nic_from_xs_be()
Date: Mon, 25 Nov 2013 12:38:56 +0100 [thread overview]
Message-ID: <529336D0.9000707@citrix.com> (raw)
In-Reply-To: <1385377973-21401-4-git-send-email-andrew.cooper3@citrix.com>
On 25/11/13 12:12, Andrew Cooper wrote:
> Coverity ID: 1055886
>
> The callers of xs_read() is required to free the allocated memory. Also avoid
> calling libxl__parse_mac(NULL,) if the second xs_read() fails.
>
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> CC: Ian Campbell <Ian.Campbell@citrix.com>
> CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
> ---
> tools/libxl/libxl.c | 11 +++++++----
> 1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
> index 2b847ef..d8dae3e 100644
> --- a/tools/libxl/libxl.c
> +++ b/tools/libxl/libxl.c
> @@ -2983,14 +2983,15 @@ static void libxl__device_nic_from_xs_be(libxl__gc *gc,
> libxl_ctx *ctx = libxl__gc_owner(gc);
> unsigned int len;
> char *tmp;
> - int rc;
>
> libxl_device_nic_init(nic);
>
> tmp = xs_read(ctx->xsh, XBT_NULL,
> libxl__sprintf(gc, "%s/handle", be_path), &len);
It might be easier to just use libxl__xs_read_checked since you are
changing that code.
> - if ( tmp )
> + if ( tmp ) {
> nic->devid = atoi(tmp);
> + free(tmp);
> + }
> else
> nic->devid = 0;
>
> @@ -2998,10 +2999,12 @@ static void libxl__device_nic_from_xs_be(libxl__gc *gc,
>
> tmp = xs_read(ctx->xsh, XBT_NULL,
> libxl__sprintf(gc, "%s/mac", be_path), &len);
> - rc = libxl__parse_mac(tmp, nic->mac);
> - if (rc)
> +
> + if ( !tmp || libxl__parse_mac(tmp, nic->mac) != 0 )
> memset(nic->mac, 0, sizeof(nic->mac));
>
> + free(tmp);
> +
> nic->ip = xs_read(ctx->xsh, XBT_NULL,
> libxl__sprintf(gc, "%s/ip", be_path), &len);
>
>
next prev parent reply other threads:[~2013-11-25 11:38 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-25 11:12 [PATCH 0/4] Coverity fixes for tools/libxl Andrew Cooper
2013-11-25 11:12 ` [PATCH 1/4] tools/libxl: Avoid deliberate NULL pointer dereference Andrew Cooper
2013-11-25 12:32 ` Ian Jackson
2013-11-25 11:12 ` [PATCH 2/4] tools/libxl: Fix integer overflows in sched_sedf_domain_set() Andrew Cooper
2013-11-25 12:35 ` Ian Jackson
2013-11-25 11:12 ` [PATCH 3/4] tools/libxl: Fix libxl__device_nic_from_xs_be() Andrew Cooper
2013-11-25 11:38 ` Roger Pau Monné [this message]
2013-11-25 15:19 ` [Patch v2 " Andrew Cooper
2013-11-25 18:52 ` Roger Pau Monné
2013-11-25 20:49 ` [Patch v3 " Andrew Cooper
2013-11-26 8:11 ` Roger Pau Monné
2013-11-26 11:32 ` Ian Jackson
2013-11-26 11:42 ` Andrew Cooper
2013-11-26 12:09 ` Ian Jackson
2013-11-26 13:58 ` Andrew Cooper
2013-11-26 15:08 ` Ian Jackson
2013-11-26 15:15 ` Andrew Cooper
2013-11-26 15:39 ` Ian Jackson
2013-12-09 13:35 ` Andrew Cooper
2013-12-18 11:11 ` Ian Campbell
2013-12-18 11:10 ` Ian Campbell
2013-11-25 12:38 ` [PATCH " Ian Jackson
2013-11-25 11:12 ` [PATCH 4/4] tools/libxl: Fix memory leak in sched_domain_output() Andrew Cooper
2013-11-25 13:46 ` Ian Jackson
2013-11-25 13:48 ` Andrew Cooper
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=529336D0.9000707@citrix.com \
--to=roger.pau@citrix.com \
--cc=Ian.Campbell@citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=xen-devel@lists.xen.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).