diff options
author | Swapnil Ingle <swapnil.ingle@nutanix.com> | 2019-08-30 12:53:54 -0400 |
---|---|---|
committer | Felipe Franciosi <felipe@nutanix.com> | 2019-09-05 16:45:35 +0100 |
commit | 5f573729efd3d3aa7c63c7715f461c832559395f (patch) | |
tree | 6077d9cd17fa529a32fbfe0b08a3b007aa4e9b25 /kmod | |
parent | 4eed2dfaa686fa521423a14039b12c25f72a0881 (diff) | |
download | libvfio-user-5f573729efd3d3aa7c63c7715f461c832559395f.zip libvfio-user-5f573729efd3d3aa7c63c7715f461c832559395f.tar.gz libvfio-user-5f573729efd3d3aa7c63c7715f461c832559395f.tar.bz2 |
muser: fix libmuser_mmap_dev()
--Fix addr passed to vm_insert_page()
The addr passed to vm_insert_page() should start from vm_start and
incremented by PAGE_SIZE
hence 'i' must be used in the calculation and not cur_pgidx(which is the
index to fond the page)
--Add new pages index to new_pgs
new_pgs[] is an array of newly allocated pages, it is used for the
cleanup in case of failure. It must be populated by the page_index of
new allocated pages.
Signed-off-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
Diffstat (limited to 'kmod')
-rw-r--r-- | kmod/muser.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/kmod/muser.c b/kmod/muser.c index a4ec3fb..95c1a05 100644 --- a/kmod/muser.c +++ b/kmod/muser.c @@ -519,9 +519,10 @@ static int libmuser_mmap_dev(struct file *fp, struct vm_area_struct *vma) ret = -ENOMEM; goto free_pg; } + new_pgs[i] = cur_pgidx; } - addr = vma->vm_start + (cur_pgidx << PAGE_SHIFT); + addr = vma->vm_start + (i << PAGE_SHIFT); ret = vm_insert_page(vma, addr, pg); if (unlikely(ret)) goto free_pg; |