All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Ian Campbell <ian.campbell@citrix.com>,
	ian.jackson@eu.citrix.com, wei.liu2@citrix.com,
	xen-devel@lists.xen.org
Subject: Re: [PATCH] tools: libxl: make it illegal to pass libxl__realloc(gc) a non-gc ptr
Date: Wed, 10 Feb 2016 17:33:44 +0000	[thread overview]
Message-ID: <56BB7478.9090006@citrix.com> (raw)
In-Reply-To: <1455125223-4205-1-git-send-email-ian.campbell@citrix.com>

On 10/02/16 17:27, Ian Campbell wrote:
> That is, if gc is not NOGC and ptr is not NULL then ptr must be
> associated gc.
>
> Currently in this case the new_ptr would not be registered with any
> gc, which Coverity rightly points out would be a memory leak.
>
> It would also be possible to fix this by adding a libxl__ptr_add() at
> the same point, however semantically it seems like a programming error
> to gc-realloc a pointer which is not associated with the gc in
> question, so treat it as such.
>
> Compile tested only, this change could expose latent bugs.
>
> Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
> ---
>  tools/libxl/libxl_internal.c | 7 +++++++
>  tools/libxl/libxl_internal.h | 4 +++-
>  2 files changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/tools/libxl/libxl_internal.c b/tools/libxl/libxl_internal.c
> index 328046b..179d618 100644
> --- a/tools/libxl/libxl_internal.c
> +++ b/tools/libxl/libxl_internal.c
> @@ -122,6 +122,13 @@ void *libxl__realloc(libxl__gc *gc, void *ptr, size_t new_size)
>                  break;
>              }
>          }
> +        /*
> +         * If we get here then ptr was not previously registered with
> +         * this gc.
> +         */
> +        LOG(CRITICAL,
> +            "libxl__realloc on a pointer which tracked by the given gc");

"is not" ?

~Andrew

  reply	other threads:[~2016-02-10 17:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-10 17:27 [PATCH] tools: libxl: make it illegal to pass libxl__realloc(gc) a non-gc ptr Ian Campbell
2016-02-10 17:33 ` Andrew Cooper [this message]
2016-02-10 17:44   ` Ian Campbell

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=56BB7478.9090006@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=ian.campbell@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=wei.liu2@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.