summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2018-05-29 16:15:12 +0200
committerChristoph Hellwig <hch@lst.de>2018-05-31 18:35:36 +0200
commit2550bbfd495227945e17ed1fa1c05bce4753b86b (patch)
tree4d687b27cafda181d5d0ee010127ea54e5e219a0 /lib
parent267d2e18a281c965229a3c3ccce51c471f9c4f8a (diff)
dma-direct: don't crash on device without dma_mask
Print a useful warning instead. Reported-by: Finn Thain <fthain@telegraphics.com.au> Tested-by: Finn Thain <fthain@telegraphics.com.au> Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/dma-direct.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/dma-direct.c b/lib/dma-direct.c
index a48f94eff62e..8be8106270c2 100644
--- a/lib/dma-direct.c
+++ b/lib/dma-direct.c
@@ -34,6 +34,13 @@ check_addr(struct device *dev, dma_addr_t dma_addr, size_t size,
const char *caller)
{
if (unlikely(dev && !dma_capable(dev, dma_addr, size))) {
+ if (!dev->dma_mask) {
+ dev_err(dev,
+ "%s: call on device without dma_mask\n",
+ caller);
+ return false;
+ }
+
if (*dev->dma_mask >= DMA_BIT_MASK(32)) {
dev_err(dev,
"%s: overflow %pad+%zu of device mask %llx\n",