]> Projects (at) Tadryanom (dot) Me - AdrOS.git/commit
Fix initrd LZ4 OOM: use page-level allocation instead of kmalloc
authorTulio A M Mendes <[email protected]>
Sun, 19 Apr 2026 01:25:23 +0000 (22:25 -0300)
committerTulio A M Mendes <[email protected]>
Sun, 19 Apr 2026 01:25:23 +0000 (22:25 -0300)
commit267ba8074e567232bfff3f748dd7abda5407a8c9
tree389cfe1ea8cda1961ab5481f4282a255fb64d2b5
parentb121d0e88b63f8189e00f8a57a5fc822c64c2a84
Fix initrd LZ4 OOM: use page-level allocation instead of kmalloc

initrd_init used kmalloc() to allocate the decompression buffer for
LZ4-compressed initrd images. The kernel buddy heap is only 8 MB, so
a 4 MB allocation (the default content size) can easily fail due to
fragmentation from earlier allocations, producing:

  [HEAP] OOM: kmalloc failed.
  [INITRD] OOM decompressing LZ4 (4194304 bytes)

This was especially likely with custom initrd images compressed with
lz4 -1 or -9, which can declare larger content sizes.

Replace kmalloc(orig_sz) with initrd_alloc_pages(), which allocates
individual physical pages via pmm_alloc_page() and maps them into a
dedicated virtual region (0xD0800000, above the 8MB heap). This
bypasses the buddy allocator entirely, using the physical memory
manager directly. On OOM, already-mapped pages are rolled back.

Both LZ4 Frame and legacy LZ4B paths are updated.
src/drivers/initrd.c