From: "Jan Beulich" <JBeulich@suse.com>
To: "Ian Campbell" <ian.campbell@citrix.com>
Cc: "Haogang Chen" <haogangchen@gmail.com>,
"Jeremy Fitzhardinge" <jeremy@goop.org>,
<virtualization@lists.linux-foundation.org>,
<xen-devel@lists.xensource.com>,
"Konrad Rzeszutek Wilk" <konrad.wilk@oracle.com>,
<linux-kernel@vger.kernel.org>
Subject: Re: [Xen-devel] [PATCH 2/2] xen/xenbus: don't reimplement kvasprintf via a fixed size buffer
Date: Wed, 04 Jan 2012 11:58:56 +0000 [thread overview]
Message-ID: <4F044D10020000780006A5B4@nat28.tlf.novell.com> (raw)
In-Reply-To: <1325677192-10459-2-git-send-email-ian.campbell@citrix.com>
>>> On 04.01.12 at 12:39, Ian Campbell <ian.campbell@citrix.com> wrote:
> Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
> Cc: Haogang Chen <haogangchen@gmail.com>
> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> Cc: Jeremy Fitzhardinge <jeremy@goop.org>
> Cc: xen-devel@lists.xensource.com
> Cc: virtualization@lists.linux-foundation.org
> Cc: linux-kernel@vger.kernel.org
> ---
> drivers/xen/xenbus/xenbus_xs.c | 17 +++++++----------
> 1 files changed, 7 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/xen/xenbus/xenbus_xs.c b/drivers/xen/xenbus/xenbus_xs.c
> index 6f0121e..226d1ac 100644
> --- a/drivers/xen/xenbus/xenbus_xs.c
> +++ b/drivers/xen/xenbus/xenbus_xs.c
> @@ -532,21 +532,18 @@ int xenbus_printf(struct xenbus_transaction t,
> {
> va_list ap;
> int ret;
> -#define PRINTF_BUFFER_SIZE 4096
> - char *printf_buffer;
> -
> - printf_buffer = kmalloc(PRINTF_BUFFER_SIZE, GFP_NOIO | __GFP_HIGH);
> - if (printf_buffer == NULL)
> - return -ENOMEM;
> + char *buf;
>
> va_start(ap, fmt);
> - ret = vsnprintf(printf_buffer, PRINTF_BUFFER_SIZE, fmt, ap);
> + buf = kvasprintf(GFP_NOIO | __GFP_HIGH, fmt, ap);
> va_end(ap);
>
> - BUG_ON(ret > PRINTF_BUFFER_SIZE-1);
> - ret = xenbus_write(t, dir, node, printf_buffer);
> + if (!buf)
> + return -ENOMEM;
> +
> + ret = xenbus_write(t, dir, node, buf);
>
> - kfree(printf_buffer);
> + kfree(buf);
>
> return ret;
> }
> --
> 1.7.2.5
>
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xensource.com
> http://lists.xensource.com/xen-devel
next prev parent reply other threads:[~2012-01-04 11:58 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-03 19:42 [PATCH] XEN: xenbus: integer overflow in process_msg() Haogang Chen
2012-01-04 9:24 ` Ian Campbell
2012-01-04 9:34 ` Ian Campbell
2012-01-04 11:39 ` [PATCH 0/2] xen: Miscelaneous xenbus cleanups Ian Campbell
2012-01-04 11:39 ` [PATCH 1/2] xenbus: maximum buffer size is XENSTORE_PAYLOAD_MAX Ian Campbell
2012-01-04 11:39 ` [PATCH 2/2] xen/xenbus: don't reimplement kvasprintf via a fixed size buffer Ian Campbell
2012-01-04 11:58 ` Jan Beulich [this message]
2012-01-04 15:12 ` [Xen-devel] " Konrad Rzeszutek Wilk
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=4F044D10020000780006A5B4@nat28.tlf.novell.com \
--to=jbeulich@suse.com \
--cc=haogangchen@gmail.com \
--cc=ian.campbell@citrix.com \
--cc=jeremy@goop.org \
--cc=konrad.wilk@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=virtualization@lists.linux-foundation.org \
--cc=xen-devel@lists.xensource.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
all inboxes | Powered by JetHome®