diff options
author | Nisheeth Bhat <nisheeth.bhat@intel.com> | 2011-09-15 16:52:24 -0400 |
---|---|---|
committer | Matthew Wilcox <matthew.r.wilcox@intel.com> | 2011-11-04 15:53:04 -0400 |
commit | d1a490e026efb22851ed60588b5fad1281d80ec3 (patch) | |
tree | 46f3b9050272ed0e41e364eeebf4e1eebb7bf79e /drivers/block | |
parent | d0ba1e497bca83a3d353eb47c9658afc54d83228 (diff) |
NVMe: Fix calls to dma_unmap_sg
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>
Diffstat (limited to 'drivers/block')
-rw-r--r-- | drivers/block/nvme.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/drivers/block/nvme.c b/drivers/block/nvme.c index 5843409cac6d..a7f82fbdaf87 100644 --- a/drivers/block/nvme.c +++ b/drivers/block/nvme.c | |||
@@ -1021,13 +1021,12 @@ static int nvme_map_user_pages(struct nvme_dev *dev, int write, | |||
1021 | } | 1021 | } |
1022 | 1022 | ||
1023 | static void nvme_unmap_user_pages(struct nvme_dev *dev, int write, | 1023 | static void nvme_unmap_user_pages(struct nvme_dev *dev, int write, |
1024 | unsigned long addr, int length, | 1024 | unsigned long addr, int length, struct scatterlist *sg) |
1025 | struct scatterlist *sg, int nents) | ||
1026 | { | 1025 | { |
1027 | int i, count; | 1026 | int i, count; |
1028 | 1027 | ||
1029 | count = DIV_ROUND_UP(offset_in_page(addr) + length, PAGE_SIZE); | 1028 | count = DIV_ROUND_UP(offset_in_page(addr) + length, PAGE_SIZE); |
1030 | dma_unmap_sg(&dev->pci_dev->dev, sg, nents, DMA_FROM_DEVICE); | 1029 | dma_unmap_sg(&dev->pci_dev->dev, sg, count, DMA_FROM_DEVICE); |
1031 | 1030 | ||
1032 | for (i = 0; i < count; i++) | 1031 | for (i = 0; i < count; i++) |
1033 | put_page(sg_page(&sg[i])); | 1032 | 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) | |||
1089 | else | 1088 | else |
1090 | status = nvme_submit_sync_cmd(nvmeq, &c, NULL, IO_TIMEOUT); | 1089 | status = nvme_submit_sync_cmd(nvmeq, &c, NULL, IO_TIMEOUT); |
1091 | 1090 | ||
1092 | nvme_unmap_user_pages(dev, io.opcode & 1, io.addr, length, sg, nents); | 1091 | nvme_unmap_user_pages(dev, io.opcode & 1, io.addr, length, sg); |
1093 | nvme_free_prps(dev, prps); | 1092 | nvme_free_prps(dev, prps); |
1094 | return status; | 1093 | return status; |
1095 | } | 1094 | } |
@@ -1135,8 +1134,7 @@ static int nvme_user_admin_cmd(struct nvme_ns *ns, | |||
1135 | else | 1134 | else |
1136 | status = nvme_submit_admin_cmd(dev, &c, NULL); | 1135 | status = nvme_submit_admin_cmd(dev, &c, NULL); |
1137 | if (cmd.data_len) { | 1136 | if (cmd.data_len) { |
1138 | nvme_unmap_user_pages(dev, 0, cmd.addr, cmd.data_len, sg, | 1137 | nvme_unmap_user_pages(dev, 0, cmd.addr, cmd.data_len, sg); |
1139 | nents); | ||
1140 | nvme_free_prps(dev, prps); | 1138 | nvme_free_prps(dev, prps); |
1141 | } | 1139 | } |
1142 | return status; | 1140 | return status; |