dma-mapping: fix lack of DMA address assignment in generic remap allocator
authorMarek Szyprowski <m.szyprowski@samsung.com>
Wed, 5 Dec 2018 10:14:01 +0000 (11:14 +0100)
committerChristoph Hellwig <hch@lst.de>
Wed, 5 Dec 2018 13:49:10 +0000 (05:49 -0800)
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>
Tested-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
kernel/dma/remap.c

index 68a64e3ff6a15f3c8b201e73a5b27b72d569d0f6..8a44317cfc1ae75335bd08229abcc1239a437069 100644 (file)
@@ -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;
 }