/* @buffer: start of memory to be freed Return: status code  */
efi_status_t efi_free_pool(void *buffer)
/* @buffer: start of memory to be freed Return: status code  */
efi_status_t efi_free_pool(void *buffer)
{
	efi_status_t ret;
	struct efi_pool_allocation *alloc;
	if (!buffer)
		return EFI_INVALID_PARAMETER;
	ret = efi_check_allocated((uintptr_t)buffer, true);
	if (ret != EFI_SUCCESS)
		return ret;
	alloc = container_of(buffer, struct efi_pool_allocation, data);
	if (((uintptr_t)alloc & EFI_PAGE_MASK) ||
	    alloc->checksum != checksum(alloc)) {
		printf("%s: illegal free 0x%p\n", __func__, buffer);
		return EFI_INVALID_PARAMETER;
	}
	alloc->checksum = 0;
	ret = efi_free_pages((uintptr_t)alloc, alloc->num_pages);
	return ret;
}