[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 3/3] mm: Temporarily disable grub_mm_debug while calling grub_vpr
From: |
Glenn Washburn |
Subject: |
[PATCH 3/3] mm: Temporarily disable grub_mm_debug while calling grub_vprintf in grub_printf |
Date: |
Tue, 15 Feb 2022 12:36:43 -0600 |
To prevent infinite recursion when grub_mm_debug is on, disable it when
calling grub_vprintf. One such call loop is:
grub_vprintf -> parse_printf_args -> parse_printf_arg_fmt
-> grub_debug_calloc -> grub_printf -> grub_vprintf
Signed-off-by: Glenn Washburn <development@efficientek.com>
---
grub-core/kern/misc.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c
index de40f566d6..cd6f460a21 100644
--- a/grub-core/kern/misc.c
+++ b/grub-core/kern/misc.c
@@ -113,10 +113,29 @@ grub_printf (const char *fmt, ...)
va_list ap;
int ret;
+#if defined(MM_DEBUG) && !defined(GRUB_UTIL) && !defined (GRUB_MACHINE_EMU)
+ /*
+ * To prevent infinite recursion when grub_mm_debug is on, disable it
+ * when calling grub_vprintf. One such call loop is:
+ * grub_vprintf -> parse_printf_args -> parse_printf_arg_fmt
+ * -> grub_debug_calloc -> grub_printf -> grub_vprintf
+ */
+ int grub_mm_debug_save = 0;
+ if (grub_mm_debug)
+ {
+ grub_mm_debug_save = grub_mm_debug;
+ grub_mm_debug = 0;
+ }
+#endif
+
va_start (ap, fmt);
ret = grub_vprintf (fmt, ap);
va_end (ap);
+#if defined(MM_DEBUG) && !defined(GRUB_UTIL) && !defined (GRUB_MACHINE_EMU)
+ grub_mm_debug = grub_mm_debug_save;
+#endif
+
return ret;
}
--
2.27.0