Commit 2550bbfd authored by Christoph Hellwig's avatar Christoph Hellwig

dma-direct: don't crash on device without dma_mask

Print a useful warning instead.
Reported-by: default avatarFinn Thain <fthain@telegraphics.com.au>
Tested-by: default avatarFinn Thain <fthain@telegraphics.com.au>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
parent 267d2e18
...@@ -34,6 +34,13 @@ check_addr(struct device *dev, dma_addr_t dma_addr, size_t size, ...@@ -34,6 +34,13 @@ check_addr(struct device *dev, dma_addr_t dma_addr, size_t size,
const char *caller) const char *caller)
{ {
if (unlikely(dev && !dma_capable(dev, dma_addr, size))) { 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)) { if (*dev->dma_mask >= DMA_BIT_MASK(32)) {
dev_err(dev, dev_err(dev,
"%s: overflow %pad+%zu of device mask %llx\n", "%s: overflow %pad+%zu of device mask %llx\n",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment