]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - arch/arm64/mm/dma-mapping.c
arm64: Warn on NULL device structure for dma APIs
[karo-tx-linux.git] / arch / arm64 / mm / dma-mapping.c
index 4bd7579ec9e6029746cb0fc485a255056fbaf2ff..83e643131e1059ef233eeb79f072858f02eb4161 100644 (file)
@@ -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);
 }