xen/xenbus: don't reimplement kvasprintf via a fixed size buffer

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Cc: Haogang Chen <haogangchen@gmail.com>
Acked-by: Jan Beulich <JBeulich@suse.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
This commit is contained in:
Ian Campbell 2012-01-04 11:39:52 +00:00 committed by Konrad Rzeszutek Wilk
parent 50bf73796e
commit a800651e88

View file

@ -532,21 +532,18 @@ int xenbus_printf(struct xenbus_transaction t,
{ {
va_list ap; va_list ap;
int ret; int ret;
#define PRINTF_BUFFER_SIZE 4096 char *buf;
char *printf_buffer;
printf_buffer = kmalloc(PRINTF_BUFFER_SIZE, GFP_NOIO | __GFP_HIGH);
if (printf_buffer == NULL)
return -ENOMEM;
va_start(ap, fmt); va_start(ap, fmt);
ret = vsnprintf(printf_buffer, PRINTF_BUFFER_SIZE, fmt, ap); buf = kvasprintf(GFP_NOIO | __GFP_HIGH, fmt, ap);
va_end(ap); va_end(ap);
BUG_ON(ret > PRINTF_BUFFER_SIZE-1); if (!buf)
ret = xenbus_write(t, dir, node, printf_buffer); return -ENOMEM;
kfree(printf_buffer); ret = xenbus_write(t, dir, node, buf);
kfree(buf);
return ret; return ret;
} }