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 removed only the first module on the list not freeing all the others.
Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
Reviewed-by: Sudhakar Kuppusamy <sudhakar@linux.ibm.com>
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);
}