summaryrefslogtreecommitdiff
path: root/include/linux/dma-direct.h
diff options
context:
space:
mode:
authorThomas Tai <thomas.tai@oracle.com>2020-09-17 19:43:03 +0300
committerChristoph Hellwig <hch@lst.de>2020-09-17 19:43:20 +0300
commitf959dcd6ddfd29235030e8026471ac1b022ad2b0 (patch)
treeb3bb71e9171c97f693240bdeb3e9ad2f0a5d580c /include/linux/dma-direct.h
parenta92df4f62fda02e6b141e2b0bb52ccc486264b1c (diff)
downloadlinux-f959dcd6ddfd29235030e8026471ac1b022ad2b0.tar.xz
dma-direct: Fix potential NULL pointer dereference
When booting the kernel v5.9-rc4 on a VM, the kernel would panic when printing a warning message in swiotlb_map(). The dev->dma_mask must not be a NULL pointer when calling the dma mapping layer. A NULL pointer check can potentially avoid the panic. Signed-off-by: Thomas Tai <thomas.tai@oracle.com> Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'include/linux/dma-direct.h')
-rw-r--r--include/linux/dma-direct.h3
1 files changed, 0 insertions, 3 deletions
diff --git a/include/linux/dma-direct.h b/include/linux/dma-direct.h
index 805010ea5346..2929685e88aa 100644
--- a/include/linux/dma-direct.h
+++ b/include/linux/dma-direct.h
@@ -62,9 +62,6 @@ static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size,
{
dma_addr_t end = addr + size - 1;
- if (!dev->dma_mask)
- return false;
-
if (is_ram && !IS_ENABLED(CONFIG_ARCH_DMA_ADDR_T_64BIT) &&
min(addr, end) < phys_to_dma(dev, PFN_PHYS(min_low_pfn)))
return false;