dcavalca / rpms / grub2

Forked from rpms/grub2 3 years ago
Clone

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

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