Skip to content

Commit

Permalink
NVMe: Check for DMA mapping failure
Browse files Browse the repository at this point in the history
If dma_map_sg returns 0 (failure), we need to fail the I/O.

Signed-off-by: Matthew Wilcox <matthew.r.wilcox@intel.com>
  • Loading branch information
Matthew Wilcox committed Nov 4, 2011
1 parent d567760 commit 1974b1a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion drivers/block/nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,8 @@ static int nvme_submit_bio_queue(struct nvme_queue *nvmeq, struct nvme_ns *ns,
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;
Expand All @@ -471,6 +472,11 @@ static int nvme_submit_bio_queue(struct nvme_queue *nvmeq, struct nvme_ns *ns,

return 0;

mapping_failed:
free_nbio(nvmeq, nbio);
bio_endio(bio, -ENOMEM);
return 0;

free_nbio:
free_nbio(nvmeq, nbio);
congestion:
Expand Down

0 comments on commit 1974b1a

Please sign in to comment.