Skip to content

Commit 739cf9f

Browse files
committed
loader/mips64/linux: properly prepare memory for initrd
... instead of allocating a fixed amount at initialization
1 parent 280ea0f commit 739cf9f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

grub-core/loader/mips64/linux.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
1818
*/
1919

20+
#include <grub/types.h>
2021
#include <grub/efi/api.h>
2122
#include <grub/efi/efi.h>
2223
#include <grub/elf.h>
@@ -500,6 +501,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
500501
{
501502
grub_size_t size = 0;
502503
void *initrd_dest;
504+
void *balloon = NULL;
503505
grub_err_t err;
504506
struct grub_linux_initrd_context initrd_ctx = { 0, 0, 0 };
505507

@@ -517,6 +519,14 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
517519

518520
size = grub_get_initrd_size (&initrd_ctx);
519521

522+
// make sure we can allocate sufficient memory for the initrd
523+
balloon = grub_memalign (0x10000, size);
524+
if (!balloon)
525+
goto fail;
526+
else
527+
// free this region for the relocator
528+
grub_free(balloon);
529+
520530
{
521531
grub_relocator_chunk_t ch;
522532
err = grub_relocator_alloc_chunk_align (relocator, &ch,

0 commit comments

Comments
 (0)