Index: stand/efi/libefi/efipart.c =================================================================== --- stand/efi/libefi/efipart.c +++ stand/efi/libefi/efipart.c @@ -977,10 +977,12 @@ struct disk_devdesc *dev = (struct disk_devdesc *)devdata; pdinfo_t *pd; EFI_BLOCK_IO *blkio; + EFI_PHYSICAL_ADDRESS addr = 0; uint64_t off, disk_blocks, d_offset = 0; char *blkbuf; size_t blkoff, blksz; int error; + uint32_t npages; uint64_t diskend, readstart; if (dev == NULL || blk < 0) @@ -1040,11 +1042,13 @@ /* * The buffer size is not a multiple of the media block size. */ - blkbuf = malloc(blkio->Media->BlockSize); - if (blkbuf == NULL) + npages = EFI_SIZE_TO_PAGES(blkio->Media->BlockSize); + error = BS->AllocatePages(AllocateAnyPages, EfiLoaderData, npages, + &addr); + if (EFI_ERROR(error)) return (ENOMEM); - error = 0; + blkbuf = (char *)addr; blk = off / blkio->Media->BlockSize; blkoff = off % blkio->Media->BlockSize; blksz = blkio->Media->BlockSize - blkoff; @@ -1062,6 +1066,6 @@ blksz = blkio->Media->BlockSize; } - free(blkbuf); + BS->FreePages(addr, npages); return (error); }