Skip to content

Commit

Permalink
Fix buggy kmem_{v}asprintf() functions
Browse files Browse the repository at this point in the history
When the kvasprintf() call fails they should reset the arguments
by calling va_start()/va_copy() and va_end() inside the loop,
otherwise they'll try to read more arguments rather than starting
over and reading them from the beginning.

Signed-off-by: Ricardo M. Correia <ricardo.correia@oracle.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
  • Loading branch information
Ricardo M. Correia authored and behlendorf committed Jul 20, 2010
1 parent 9dd5d13 commit 2c762de
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions module/spl/spl-kmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,11 @@ kmem_vasprintf(const char *fmt, va_list ap)
va_list aq;
char *ptr;

va_copy(aq, ap);
do {
va_copy(aq, ap);
ptr = kvasprintf(GFP_KERNEL, fmt, aq);
va_end(aq);
} while (ptr == NULL);
va_end(aq);

return ptr;
}
Expand All @@ -261,11 +261,11 @@ kmem_asprintf(const char *fmt, ...)
va_list ap;
char *ptr;

va_start(ap, fmt);
do {
va_start(ap, fmt);
ptr = kvasprintf(GFP_KERNEL, fmt, ap);
va_end(ap);
} while (ptr == NULL);
va_end(ap);

return ptr;
}
Expand Down

0 comments on commit 2c762de

Please sign in to comment.