History

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.

Benjamin Gray committed 3 years ago

Commit 735faf91 parent 5efb6851 file · +2 −9Browse files

Unified · Split

init/initramfs.c+2−9
@@ -60,15 +60,8 @@ static void __init error(char *x) · 59 unmodified lines
60 message = x;60 message = x;
61}61}
62 62
63static void panic_show_mem(const char *fmt, ...)63#define panic_show_mem(fmt, ...) \
64{64 ({ show_mem(0, NULL); panic(fmt, ##__VA_ARGS__); })
65 va_list args;
66
67 show_mem(0, NULL);
68 va_start(args, fmt);
69 panic(fmt, args);
70 va_end(args);
71}
72 65
73/* link hash */66/* link hash */
74 67