From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from bombadil.infradead.org ([198.137.202.9]:35434 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753128AbbJPGCu (ORCPT ); Fri, 16 Oct 2015 02:02:50 -0400 From: Christoph Hellwig To: axboe@fb.com Cc: keith.busch@intel.com, james_p_freyensee@linux.intel.com, jay.e.sternberg@intel.com, phil.cayton@intel.com, mlin@kernel.org, linux-nvme@lists.infradead.org, stable@vger.kernel.org Subject: [PATCH 01/18] nvme: add missing unmaps in nvme_queue_rq Date: Fri, 16 Oct 2015 07:58:31 +0200 Message-Id: <1444975128-8768-2-git-send-email-hch@lst.de> In-Reply-To: <1444975128-8768-1-git-send-email-hch@lst.de> References: <1444975128-8768-1-git-send-email-hch@lst.de> Sender: stable-owner@vger.kernel.org List-ID: 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 --- drivers/nvme/host/pci.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 22d8375..2f05292 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -906,19 +906,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; + } } } -- 1.9.1