summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorThomas Tai <thomas.tai@oracle.com>2020-09-17 18:43:03 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-10-29 10:12:15 +0100
commit4e57482e8440fac7137832629109730ea4b267aa (patch)
tree6d3a954ea42e59296868c1b02e284e2cfe2b29cf /include
parent48464c17bd642ee0b52c02a1ce22108b7345087b (diff)
downloadlinux-stable-4e57482e8440fac7137832629109730ea4b267aa.tar.gz
linux-stable-4e57482e8440fac7137832629109730ea4b267aa.tar.bz2
linux-stable-4e57482e8440fac7137832629109730ea4b267aa.zip
dma-direct: Fix potential NULL pointer dereference
[ Upstream commit f959dcd6ddfd29235030e8026471ac1b022ad2b0 ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'include')
-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 6e87225600ae..064870844f06 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;