From 2550bbfd495227945e17ed1fa1c05bce4753b86b Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Tue, 29 May 2018 16:15:12 +0200 Subject: [PATCH] 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 --- lib/dma-direct.c | 7 +++++++ 1 file changed, 7 insertions(+) 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", -- GitLab