Skip to content

Commit

Permalink
nvme: add missing unmaps in nvme_queue_rq
Browse files Browse the repository at this point in the history
When we fail various metadata related operations in nvme_queue_rq we
need to unmap the data SGL.

Cc: stable@vger.kernel.org
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
  • Loading branch information
Christoph Hellwig authored and Jens Axboe committed Nov 24, 2015
1 parent c5c9f25 commit bf508e9
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions drivers/nvme/host/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -896,19 +896,28 @@ static int nvme_queue_rq(struct blk_mq_hw_ctx *hctx,
goto retry_cmd;
}
if (blk_integrity_rq(req)) {
if (blk_rq_count_integrity_sg(req->q, req->bio) != 1)
if (blk_rq_count_integrity_sg(req->q, req->bio) != 1) {
dma_unmap_sg(dev->dev, iod->sg, iod->nents,
dma_dir);
goto error_cmd;
}

sg_init_table(iod->meta_sg, 1);
if (blk_rq_map_integrity_sg(
req->q, req->bio, iod->meta_sg) != 1)
req->q, req->bio, iod->meta_sg) != 1) {
dma_unmap_sg(dev->dev, iod->sg, iod->nents,
dma_dir);
goto error_cmd;
}

if (rq_data_dir(req))
nvme_dif_remap(req, nvme_dif_prep);

if (!dma_map_sg(nvmeq->q_dmadev, iod->meta_sg, 1, dma_dir))
if (!dma_map_sg(nvmeq->q_dmadev, iod->meta_sg, 1, dma_dir)) {
dma_unmap_sg(dev->dev, iod->sg, iod->nents,
dma_dir);
goto error_cmd;
}
}
}

Expand Down

0 comments on commit bf508e9

Please sign in to comment.