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

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