NVMe: Fix calls to dma_unmap_sg
authorNisheeth Bhat <nisheeth.bhat@intel.com>
Thu, 15 Sep 2011 20:52:24 +0000 (16:52 -0400)
committerMatthew Wilcox <matthew.r.wilcox@intel.com>
Fri, 4 Nov 2011 19:53:04 +0000 (15:53 -0400)
dma_unmap_sg() must be called with the same 'nents' passed to
dma_map_sg(), not the number returned from dma_map_sg().

Signed-off-by: Nisheeth Bhat <nisheeth.bhat@intel.com>
Signed-off-by: Matthew Wilcox <matthew.r.wilcox@intel.com>
drivers/block/nvme.c

index 5843409cac6d1003c9bc8b4dd46126eca941063d..a7f82fbdaf87a4f75605e4ecb3942148b5f4b2f6 100644 (file)
@@ -1021,13 +1021,12 @@ static int nvme_map_user_pages(struct nvme_dev *dev, int write,
 }
 
 static void nvme_unmap_user_pages(struct nvme_dev *dev, int write,
-                               unsigned long addr, int length,
-                               struct scatterlist *sg, int nents)
+                       unsigned long addr, int length, struct scatterlist *sg)
 {
        int i, count;
 
        count = DIV_ROUND_UP(offset_in_page(addr) + length, PAGE_SIZE);
-       dma_unmap_sg(&dev->pci_dev->dev, sg, nents, DMA_FROM_DEVICE);
+       dma_unmap_sg(&dev->pci_dev->dev, sg, count, DMA_FROM_DEVICE);
 
        for (i = 0; i < count; i++)
                put_page(sg_page(&sg[i]));
@@ -1089,7 +1088,7 @@ static int nvme_submit_io(struct nvme_ns *ns, struct nvme_user_io __user *uio)
        else
                status = nvme_submit_sync_cmd(nvmeq, &c, NULL, IO_TIMEOUT);
 
-       nvme_unmap_user_pages(dev, io.opcode & 1, io.addr, length, sg, nents);
+       nvme_unmap_user_pages(dev, io.opcode & 1, io.addr, length, sg);
        nvme_free_prps(dev, prps);
        return status;
 }
@@ -1135,8 +1134,7 @@ static int nvme_user_admin_cmd(struct nvme_ns *ns,
        else
                status = nvme_submit_admin_cmd(dev, &c, NULL);
        if (cmd.data_len) {
-               nvme_unmap_user_pages(dev, 0, cmd.addr, cmd.data_len, sg,
-                                                                       nents);
+               nvme_unmap_user_pages(dev, 0, cmd.addr, cmd.data_len, sg);
                nvme_free_prps(dev, prps);
        }
        return status;