Skip to contentSkip to conversation

arm64/xen: Delete correctly all modules loaded by xen_module

PATCH In review Frediano Ziglio via Grub-devel 3 participants 3 messages Jul 4, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm64/xen: Delete correctly all modules loaded by xen_module

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.

---
 grub-core/loader/arm64/xen_boot.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
grub-core/loader/arm64/xen_boot.c +2 -2
index 26e1472c9..731f1913a 100644
@@ -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);
   }
Signature · 7 lines
2.43.0


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Frediano Ziglio via Grub-devel

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.

Daniel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

Reviewed-by on v1 1/1
#2 lore raw
In reply to Frediano Ziglio via Grub-devel
Quoted 12 lines · Frediano Ziglio via Grub-devel

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.

---

Reviewed-by Sudhakar Kuppusamy <[email protected] <mailto:[email protected]>>
Quoted 27 lines

grub-core/loader/arm64/xen_boot.c | 4 ++--

1 file changed, 2 insertions(+), 2 deletions(-)
grub-core/loader/arm64/xen_boot.c +0 -0
index 26e1472c9..731f1913a 100644
@@ -290,9 +290,9 @@ single_binary_unload (struct xen_boot_binary *binary)

static void
all_binaries_unload (void)
{

grub-core/loader/arm64/xen_boot.c +2 -2
-  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);
  }
Signature · 7 lines
2.43.0


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel