multiboot2: Fix memory leak if grub_create_loader_cmdline() fails

Fixes: CID 292468

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
Konrad Rzeszutek Wilk 2020-06-26 10:51:43 -04:00 committed by Daniel Kiper
parent d17770857e
commit f8ad7a3dd8

View file

@ -1076,7 +1076,11 @@ grub_multiboot2_add_module (grub_addr_t start, grub_size_t size,
err = grub_create_loader_cmdline (argc, argv, newmod->cmdline, err = grub_create_loader_cmdline (argc, argv, newmod->cmdline,
newmod->cmdline_size, GRUB_VERIFY_MODULE_CMDLINE); newmod->cmdline_size, GRUB_VERIFY_MODULE_CMDLINE);
if (err) if (err)
return err; {
grub_free (newmod->cmdline);
grub_free (newmod);
return err;
}
if (modules_last) if (modules_last)
modules_last->next = newmod; modules_last->next = newmod;