Blame SOURCES/0354-dl-provide-a-fake-grub_dl_set_persistent-for-the-emu.patch

80913e
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
80913e
From: Daniel Axtens <dja@axtens.net>
80913e
Date: Thu, 30 Jul 2020 00:13:21 +1000
80913e
Subject: [PATCH] dl: provide a fake grub_dl_set_persistent for the emu target
80913e
80913e
Trying to start grub-emu with a module that calls grub_dl_set_persistent
80913e
will crash because grub-emu fakes modules and passes NULL to the module
80913e
init function.
80913e
80913e
Provide an empty function for the emu case.
80913e
80913e
Fixes: ee7808e2197c (dl: Add support for persistent modules)
80913e
Signed-off-by: Daniel Axtens <dja@axtens.net>
80913e
---
80913e
 include/grub/dl.h | 11 +++++++++++
80913e
 1 file changed, 11 insertions(+)
80913e
80913e
diff --git a/include/grub/dl.h b/include/grub/dl.h
b32e65
index f7cfe6482..877821dcb 100644
80913e
--- a/include/grub/dl.h
80913e
+++ b/include/grub/dl.h
80913e
@@ -243,11 +243,22 @@ grub_dl_get (const char *name)
80913e
   return 0;
80913e
 }
80913e
 
80913e
+#ifdef GRUB_MACHINE_EMU
80913e
+/*
80913e
+ * Under grub-emu, modules are faked and NULL is passed to GRUB_MOD_INIT.
80913e
+ * So we fake this out to avoid a NULL deref.
80913e
+ */
80913e
+static inline void
80913e
+grub_dl_set_persistent (grub_dl_t mod __attribute__((unused)))
80913e
+{
80913e
+}
80913e
+#else
80913e
 static inline void
80913e
 grub_dl_set_persistent (grub_dl_t mod)
80913e
 {
80913e
   mod->persistent = 1;
80913e
 }
80913e
+#endif
80913e
 
80913e
 static inline int
80913e
 grub_dl_is_persistent (grub_dl_t mod)