diff options
author | Laura Abbott <lauraa@codeaurora.org> | 2013-12-12 20:28:32 +0100 |
---|---|---|
committer | Catalin Marinas <catalin.marinas@arm.com> | 2013-12-19 18:44:08 +0100 |
commit | c666e8d5cae745b1515898f8b7a033c468a899d0 (patch) | |
tree | 2ad27dd51e4ef4d061e6493bf6a3a293ffc8429f /arch/arm64/mm | |
parent | arm64: Add hwcaps for crypto and CRC32 extensions. (diff) | |
download | linux-c666e8d5cae745b1515898f8b7a033c468a899d0.tar.xz linux-c666e8d5cae745b1515898f8b7a033c468a899d0.zip |
arm64: Warn on NULL device structure for dma APIs
Although parts of the DMA apis may properly check for NULL devices,
there may be some places that don't. Rather than fix up all the
possible locations, just require a non-NULL device structure to be
used for allocating/freeing.
Cc: Will Deacon <will.deacon@arm.com>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
[catalin.marinas@arm.com: s/WARN/WARN_ONCE/]
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Diffstat (limited to 'arch/arm64/mm')
-rw-r--r-- | arch/arm64/mm/dma-mapping.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c index 4bd7579ec9e6..83e643131e10 100644 --- a/arch/arm64/mm/dma-mapping.c +++ b/arch/arm64/mm/dma-mapping.c @@ -33,6 +33,11 @@ static void *arm64_swiotlb_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle, gfp_t flags, struct dma_attrs *attrs) { + if (dev == NULL) { + WARN_ONCE(1, "Use an actual device structure for DMA allocation\n"); + return NULL; + } + if (IS_ENABLED(CONFIG_ZONE_DMA32) && dev->coherent_dma_mask <= DMA_BIT_MASK(32)) flags |= GFP_DMA32; @@ -43,6 +48,11 @@ static void arm64_swiotlb_free_coherent(struct device *dev, size_t size, void *vaddr, dma_addr_t dma_handle, struct dma_attrs *attrs) { + if (dev == NULL) { + WARN_ONCE(1, "Use an actual device structure for DMA allocation\n"); + return; + } + swiotlb_free_coherent(dev, size, vaddr, dma_handle); } |