Skip to content

Commit bf508e9

Browse files
Christoph Hellwigaxboe
authored andcommitted
nvme: add missing unmaps in nvme_queue_rq
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>
1 parent c5c9f25 commit bf508e9

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

drivers/nvme/host/pci.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -896,19 +896,28 @@ static int nvme_queue_rq(struct blk_mq_hw_ctx *hctx,
896896
goto retry_cmd;
897897
}
898898
if (blk_integrity_rq(req)) {
899-
if (blk_rq_count_integrity_sg(req->q, req->bio) != 1)
899+
if (blk_rq_count_integrity_sg(req->q, req->bio) != 1) {
900+
dma_unmap_sg(dev->dev, iod->sg, iod->nents,
901+
dma_dir);
900902
goto error_cmd;
903+
}
901904

902905
sg_init_table(iod->meta_sg, 1);
903906
if (blk_rq_map_integrity_sg(
904-
req->q, req->bio, iod->meta_sg) != 1)
907+
req->q, req->bio, iod->meta_sg) != 1) {
908+
dma_unmap_sg(dev->dev, iod->sg, iod->nents,
909+
dma_dir);
905910
goto error_cmd;
911+
}
906912

907913
if (rq_data_dir(req))
908914
nvme_dif_remap(req, nvme_dif_prep);
909915

910-
if (!dma_map_sg(nvmeq->q_dmadev, iod->meta_sg, 1, dma_dir))
916+
if (!dma_map_sg(nvmeq->q_dmadev, iod->meta_sg, 1, dma_dir)) {
917+
dma_unmap_sg(dev->dev, iod->sg, iod->nents,
918+
dma_dir);
911919
goto error_cmd;
920+
}
912921
}
913922
}
914923

0 commit comments

Comments
 (0)