All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anthony PERARD <anthony.perard@citrix.com>
To: <dmitry.semenets@gmail.com>
Cc: <xen-devel@lists.xenproject.org>,
	Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>,
	Wei Liu <wl@xen.org>, Juergen Gross <jgross@suse.com>,
	Dmytro Semenets <dmytro_semenets@epam.com>
Subject: Re: [PATCH v2 2/4] tools: allow vchan XenStore paths more then 64 bytes long
Date: Tue, 27 Sep 2022 16:00:10 +0100	[thread overview]
Message-ID: <YzMP+twWGAYxWEuI@perard.uk.xensource.com> (raw)
In-Reply-To: <20220713150311.4152528-2-dmitry.semenets@gmail.com>

Hi Dmitry,

On Wed, Jul 13, 2022 at 06:03:09PM +0300, dmitry.semenets@gmail.com wrote:
> diff --git a/tools/libs/vchan/init.c b/tools/libs/vchan/init.c
> index 9195bd3b98..38658f30af 100644
> --- a/tools/libs/vchan/init.c
> +++ b/tools/libs/vchan/init.c
> @@ -259,6 +259,12 @@ static int init_xs_srv(struct libxenvchan *ctrl, int domain, const char* xs_base
>  	if (!ctrl->xs_path)
>  		return -1; 
>  
> +	buf = malloc(XENSTORE_ABS_PATH_MAX);
> +	if (!buf) {
> +		free(ctrl);
> +		return 0;

I don't understand what you are trying to achieve here. If we can't
allocate `buf`, we should return an error, right?
Also, `ctrl` isn't allocated in this function but by the caller, so I
don't think we need to free it here. Also, if it's free here, the caller
is going to continue to use the pointer, after free.

> +	}
> +
>  	xs = xs_open(0);
>  	if (!xs)
>  		goto fail;
> @@ -419,13 +426,20 @@ struct libxenvchan *libxenvchan_client_init(struct xentoollog_logger *logger,
>  {
>  	struct libxenvchan *ctrl = malloc(sizeof(struct libxenvchan));
>  	struct xs_handle *xs = NULL;
> -	char buf[64];
> +	char *buf;
>  	char *ref;
>  	int ring_ref;
>  	unsigned int len;
>  
>  	if (!ctrl)
>  		return 0;
> +
> +	buf = malloc(XENSTORE_ABS_PATH_MAX);
> +	if (!buf) {
> +		free(ctrl);
> +		return 0;

Nit: could you write NULL instead of 0 here? It would makes it much
easier to understand that we return a pointer.


Thanks,

-- 
Anthony PERARD


  parent reply	other threads:[~2022-09-27 15:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-13 15:03 [PATCH v2 1/4] tools: remove xenstore entries on vchan server closure dmitry.semenets
2022-07-13 15:03 ` [PATCH v2 2/4] tools: allow vchan XenStore paths more then 64 bytes long dmitry.semenets
2022-08-01  8:59   ` Juergen Gross
2022-08-01  9:11     ` Dmytro Semenets
2022-08-01  9:17       ` Juergen Gross
2022-09-27 15:00   ` Anthony PERARD [this message]
2022-07-13 15:03 ` [PATCH v2 3/4] tools/libs/light: Add vchan support to libxl dmitry.semenets
2022-07-13 15:03 ` [PATCH v2 4/4] tools/xl: Add pcid daemon to xl dmitry.semenets
2022-09-27 17:20   ` Anthony PERARD
2022-08-01  8:57 ` [PATCH v2 1/4] tools: remove xenstore entries on vchan server closure Juergen Gross
2022-09-22  6:29   ` Jan Beulich
2022-09-27 14:37     ` Anthony PERARD

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=YzMP+twWGAYxWEuI@perard.uk.xensource.com \
    --to=anthony.perard@citrix.com \
    --cc=dmitry.semenets@gmail.com \
    --cc=dmytro_semenets@epam.com \
    --cc=jgross@suse.com \
    --cc=oleksandr_andrushchenko@epam.com \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.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.