lib/reloacator: Fix memory leaks

Fix memory leaks in grub_relocator_alloc_chunk_align().

Fixes: CID 473844

Signed-off-by: Lidong Chen <lidong.chen@oracle.com>
Reviewed-by: Vladimir Serbinenko <phcoder@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
Lidong Chen authored and Daniel Kiper committed 2025-04-04 19:31:05 +02:00
1 parent f3f1fcecdc
commit 1d00594475
1 file changed
+4
+4
View File
@@ -1440,6 +1440,7 @@ grub_relocator_alloc_chunk_align (struct grub_relocator *rel,
break; break;
} }
grub_free (ctx.chunk);
return grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); return grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
} }
while (0); while (0);
@@ -1456,8 +1457,11 @@ grub_relocator_alloc_chunk_align (struct grub_relocator *rel,
grub_mmap_iterate (grub_relocator_alloc_chunk_align_iter, &ctx); grub_mmap_iterate (grub_relocator_alloc_chunk_align_iter, &ctx);
#endif #endif
if (!ctx.found) if (!ctx.found)
{
grub_free (ctx.chunk);
return grub_error (GRUB_ERR_BAD_OS, "couldn't find suitable memory target"); return grub_error (GRUB_ERR_BAD_OS, "couldn't find suitable memory target");
} }
}
while (1) while (1)
{ {
struct grub_relocator_chunk *chunk2; struct grub_relocator_chunk *chunk2;