Skip to content

Commit 735faf9

Browse files
BenjaminGrayNp1masahir0y
authored andcommitted
init/initramfs: Fix argument forwarding to panic() in panic_show_mem()
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>
1 parent 5efb685 commit 735faf9

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

init/initramfs.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,8 @@ static void __init error(char *x)
6060
message = x;
6161
}
6262

63-
static void panic_show_mem(const char *fmt, ...)
64-
{
65-
va_list args;
66-
67-
show_mem(0, NULL);
68-
va_start(args, fmt);
69-
panic(fmt, args);
70-
va_end(args);
71-
}
63+
#define panic_show_mem(fmt, ...) \
64+
({ show_mem(0, NULL); panic(fmt, ##__VA_ARGS__); })
7265

7366
/* link hash */
7467

0 commit comments

Comments
 (0)