We need to use FOR_LIST_ELEMENTS_SAFE instead of FOR_LIST_ELEMENTS
as single_binary_unload, called during the loop, is changing
the list using grub_list_remove.
Given the environment probably the old code simply deleted only the
first module on the list not freeing all the others.

Signed-off-by: Frediano Ziglio <frediano.zig...@cloud.com>
---
 grub-core/loader/arm64/xen_boot.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/grub-core/loader/arm64/xen_boot.c 
b/grub-core/loader/arm64/xen_boot.c
index 26e1472c9..731f1913a 100644
--- a/grub-core/loader/arm64/xen_boot.c
+++ b/grub-core/loader/arm64/xen_boot.c
@@ -290,9 +290,9 @@ single_binary_unload (struct xen_boot_binary *binary)
 static void
 all_binaries_unload (void)
 {
-  struct xen_boot_binary *binary;
+  struct xen_boot_binary *binary, *next_binary;
 
-  FOR_LIST_ELEMENTS (binary, module_head)
+  FOR_LIST_ELEMENTS_SAFE (binary, next_binary, module_head)
   {
     single_binary_unload (binary);
   }
-- 
2.43.0


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to