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