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

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