multiboot: zero mod list array

Zero the list of modules array before using it, or else we might pass
uninitialized data in unused fields of the struct that will make Xen choke.
Also add a check to make sure malloc succeeds.

Sponsored by: Citrix Systems R&D
This commit is contained in:
Roger Pau Monné 2015-04-01 10:02:28 +00:00
parent f03b8244b4
commit e1c124dc44

View File

@ -274,7 +274,14 @@ multiboot_exec(struct preloaded_file *fp)
error = EFTYPE;
goto error;
}
mb_mod = malloc(sizeof(struct multiboot_mod_list) * NUM_MODULES);
if (mb_mod == NULL) {
error = ENOMEM;
goto error;
}
bzero(mb_mod, sizeof(struct multiboot_mod_list) * NUM_MODULES);
/*
* Calculate how much memory is needed for the metatdata. We did