From a8c348db51b3bd39acaedc2033e86cbcea797890 Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Thu, 27 Apr 2017 14:29:21 +0000 Subject: [PATCH] Prefer to use real virtual address over direct map address in the linux_page_address() function in the LinuxKPI. This solves an issue where the return value from linux_page_address() is passed to kmem_free(). MFC after: 1 week Sponsored by: Mellanox Technologies --- sys/compat/linuxkpi/common/src/linux_page.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sys/compat/linuxkpi/common/src/linux_page.c b/sys/compat/linuxkpi/common/src/linux_page.c index c2adc909743d..98c6a6eae98e 100644 --- a/sys/compat/linuxkpi/common/src/linux_page.c +++ b/sys/compat/linuxkpi/common/src/linux_page.c @@ -71,14 +71,16 @@ __FBSDID("$FreeBSD$"); void * linux_page_address(struct page *page) { + + if (page->object != kmem_object && page->object != kernel_object) { #ifdef LINUXKPI_HAVE_DMAP - return ((void *)PHYS_TO_DMAP(VM_PAGE_TO_PHYS(page))); + return ((void *)PHYS_TO_DMAP(VM_PAGE_TO_PHYS(page))); #else - if (page->object != kmem_object && page->object != kernel_object) return (NULL); +#endif + } return ((void *)(uintptr_t)(VM_MIN_KERNEL_ADDRESS + IDX_TO_OFF(page->pindex))); -#endif } vm_page_t