Skip to content

Commit

Permalink
init/initramfs: Fix argument forwarding to panic() in panic_show_mem()
Browse files Browse the repository at this point in the history
Forwarding variadic argument lists can't be done by passing a va_list
to a function with signature foo(...) (as panic() has). It ends up
interpreting the va_list itself as a single argument instead of
iterating it. printf() happily accepts it of course, leading to corrupt
output.

Convert panic_show_mem() to a macro to allow forwarding the arguments.
The function is trivial enough that it's easier than trying to introduce
a vpanic() variant.

Signed-off-by: Benjamin Gray <bgray@linux.ibm.com>
Reviewed-by: Andrew Donnellan <ajd@linux.ibm.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
  • Loading branch information
BenjaminGrayNp1 authored and masahir0y committed Apr 16, 2023
1 parent 5efb685 commit 735faf9
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions init/initramfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,8 @@ static void __init error(char *x)
message = x;
}

static void panic_show_mem(const char *fmt, ...)
{
va_list args;

show_mem(0, NULL);
va_start(args, fmt);
panic(fmt, args);
va_end(args);
}
#define panic_show_mem(fmt, ...) \
({ show_mem(0, NULL); panic(fmt, ##__VA_ARGS__); })

/* link hash */

Expand Down

0 comments on commit 735faf9

Please sign in to comment.