diff options
Diffstat (limited to 'drivers/xen/privcmd.c')
-rw-r--r-- | drivers/xen/privcmd.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/drivers/xen/privcmd.c b/drivers/xen/privcmd.c index f6316127f53f..421375a9196a 100644 --- a/drivers/xen/privcmd.c +++ b/drivers/xen/privcmd.c | |||
@@ -399,13 +399,13 @@ static long privcmd_ioctl_mmap_batch(void __user *udata, int version) | |||
399 | down_write(&mm->mmap_sem); | 399 | down_write(&mm->mmap_sem); |
400 | 400 | ||
401 | vma = find_vma(mm, m.addr); | 401 | vma = find_vma(mm, m.addr); |
402 | ret = -EINVAL; | ||
403 | if (!vma || | 402 | if (!vma || |
404 | vma->vm_ops != &privcmd_vm_ops || | 403 | vma->vm_ops != &privcmd_vm_ops || |
405 | (m.addr != vma->vm_start) || | 404 | (m.addr != vma->vm_start) || |
406 | ((m.addr + (nr_pages << PAGE_SHIFT)) != vma->vm_end) || | 405 | ((m.addr + (nr_pages << PAGE_SHIFT)) != vma->vm_end) || |
407 | !privcmd_enforce_singleshot_mapping(vma)) { | 406 | !privcmd_enforce_singleshot_mapping(vma)) { |
408 | up_write(&mm->mmap_sem); | 407 | up_write(&mm->mmap_sem); |
408 | ret = -EINVAL; | ||
409 | goto out; | 409 | goto out; |
410 | } | 410 | } |
411 | if (xen_feature(XENFEAT_auto_translated_physmap)) { | 411 | if (xen_feature(XENFEAT_auto_translated_physmap)) { |
@@ -429,12 +429,16 @@ static long privcmd_ioctl_mmap_batch(void __user *udata, int version) | |||
429 | 429 | ||
430 | up_write(&mm->mmap_sem); | 430 | up_write(&mm->mmap_sem); |
431 | 431 | ||
432 | if (state.global_error && (version == 1)) { | 432 | if (version == 1) { |
433 | /* Write back errors in second pass. */ | 433 | if (state.global_error) { |
434 | state.user_mfn = (xen_pfn_t *)m.arr; | 434 | /* Write back errors in second pass. */ |
435 | state.err = err_array; | 435 | state.user_mfn = (xen_pfn_t *)m.arr; |
436 | ret = traverse_pages(m.num, sizeof(xen_pfn_t), | 436 | state.err = err_array; |
437 | &pagelist, mmap_return_errors_v1, &state); | 437 | ret = traverse_pages(m.num, sizeof(xen_pfn_t), |
438 | &pagelist, mmap_return_errors_v1, &state); | ||
439 | } else | ||
440 | ret = 0; | ||
441 | |||
438 | } else if (version == 2) { | 442 | } else if (version == 2) { |
439 | ret = __copy_to_user(m.err, err_array, m.num * sizeof(int)); | 443 | ret = __copy_to_user(m.err, err_array, m.num * sizeof(int)); |
440 | if (ret) | 444 | if (ret) |