NVMe: Check for DMA mapping failure
If dma_map_sg returns 0 (failure), we need to fail the I/O.
Signed-off-by: Matthew Wilcox <matthew.r.wilcox@intel.com>
diff --git a/drivers/block/nvme.c b/drivers/block/nvme.c
index 2948043..bfdca3a 100644
--- a/drivers/block/nvme.c
+++ b/drivers/block/nvme.c
@@ -451,7 +451,8 @@
dma_dir = DMA_FROM_DEVICE;
}
- nvme_map_bio(nvmeq->q_dmadev, nbio, bio, dma_dir, psegs);
+ if (nvme_map_bio(nvmeq->q_dmadev, nbio, bio, dma_dir, psegs) == 0)
+ goto mapping_failed;
cmnd->rw.flags = 1;
cmnd->rw.command_id = cmdid;
@@ -471,6 +472,11 @@
return 0;
+ mapping_failed:
+ free_nbio(nvmeq, nbio);
+ bio_endio(bio, -ENOMEM);
+ return 0;
+
free_nbio:
free_nbio(nvmeq, nbio);
congestion: