From: Christoph Hellwig Date: Tue, 29 May 2018 14:15:12 +0000 (+0200) Subject: dma-direct: don't crash on device without dma_mask X-Git-Tag: v5.15~8765^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2550bbfd495227945e17ed1fa1c05bce4753b86b;p=platform%2Fkernel%2Flinux-starfive.git dma-direct: don't crash on device without dma_mask Print a useful warning instead. Reported-by: Finn Thain Tested-by: Finn Thain Signed-off-by: Christoph Hellwig --- diff --git a/lib/dma-direct.c b/lib/dma-direct.c index a48f94e..8be8106 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",