diff mbox series

dma-mapping: fix lack of DMA address assignment in generic remap allocator

Message ID 20181205101401.3561-1-m.szyprowski@samsung.com
State Accepted
Commit a1da439cc0d929891f0f7372c9e03530c809068c
Headers show
Series dma-mapping: fix lack of DMA address assignment in generic remap allocator | expand

Commit Message

Marek Szyprowski Dec. 5, 2018, 10:14 a.m. UTC
Commit bfd56cd60521 ("dma-mapping: support highmem in the generic remap
allocator") replaced dma_direct_alloc_pages() with __dma_direct_alloc_pages(),
which doesn't set dma_handle and zero allocated memory. Fix it by doing this
directly in the caller function.

Fixes: bfd56cd60521 ("dma-mapping: support highmem in the generic remap allocator")
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>

---
 kernel/dma/remap.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

-- 
2.17.1

Comments

Thierry Reding Dec. 5, 2018, 12:35 p.m. UTC | #1
On Wed, Dec 05, 2018 at 11:14:01AM +0100, Marek Szyprowski wrote:
> Commit bfd56cd60521 ("dma-mapping: support highmem in the generic remap

> allocator") replaced dma_direct_alloc_pages() with __dma_direct_alloc_pages(),

> which doesn't set dma_handle and zero allocated memory. Fix it by doing this

> directly in the caller function.

> 

> Fixes: bfd56cd60521 ("dma-mapping: support highmem in the generic remap allocator")

> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>

> ---

>  kernel/dma/remap.c | 8 +++++++-

>  1 file changed, 7 insertions(+), 1 deletion(-)


Tested-by: Thierry Reding <treding@nvidia.com>
Christoph Hellwig Dec. 5, 2018, 1:49 p.m. UTC | #2
Thanks, applied.
diff mbox series

Patch

diff --git a/kernel/dma/remap.c b/kernel/dma/remap.c
index 68a64e3ff6a1..8a44317cfc1a 100644
--- a/kernel/dma/remap.c
+++ b/kernel/dma/remap.c
@@ -223,8 +223,14 @@  void *arch_dma_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle,
 	ret = dma_common_contiguous_remap(page, size, VM_USERMAP,
 			arch_dma_mmap_pgprot(dev, PAGE_KERNEL, attrs),
 			__builtin_return_address(0));
-	if (!ret)
+	if (!ret) {
 		__dma_direct_free_pages(dev, size, page);
+		return ret;
+	}
+
+	*dma_handle = phys_to_dma(dev, page_to_phys(page));
+	memset(ret, 0, size);
+
 	return ret;
 }