Skip to contentSkip to conversation

NVMe: Initialize iod nents to 0

PATCH New Keith Busch 2 participants 2 messages Nov 6, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 NVMe: Initialize iod nents to 0

For commands that do not map a scatter list, we need to initilaize the iod's number of sg entries (nents) to 0 and not unmap in this case.

Signed-off-by Keith Busch <keith.busch at intel.com>
---
 drivers/block/nvme.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
drivers/block/nvme.c +3 -1
index f9ad514..2544504 100644
@@ -334,6 +334,7 @@ nvme_alloc_iod(unsigned nseg, unsigned nbytes, gfp_t gfp)
 		iod->offset = offsetof(struct nvme_iod, sg[nseg]);
 		iod->npages = -1;
 		iod->length = nbytes;
+		iod->nents = 0;
 	}
 
 	return iod;
@@ -374,7 +375,8 @@ static void bio_completion(struct nvme_dev *dev, void *ctx,
 	struct bio *bio = iod->private;
 	u16 status = le16_to_cpup(&cqe->status) >> 1;
 
-	dma_unmap_sg(&dev->pci_dev->dev, iod->sg, iod->nents,
+	if (iod->nents)
+		dma_unmap_sg(&dev->pci_dev->dev, iod->sg, iod->nents,
 			bio_data_dir(bio) ? DMA_TO_DEVICE : DMA_FROM_DEVICE);
 	nvme_free_iod(dev, iod);
 	if (status) {
Signature · 1 line
1.7.0.4
#1 lore raw

PATCH 1/1 NVMe: Initialize iod nents to 0

Quoted 4 lines · Keith Busch

For commands that do not map a scatter list, we need to initilaize the iod's number of sg entries (nents) to 0 and not unmap in this case.

Signed-off-by Keith Busch <keith.busch at intel.com>

Thanks; applied