aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/xen/privcmd.c
diff options
context:
space:
mode:
authorMats Petersson <mats.petersson@citrix.com>2012-11-16 13:36:49 -0500
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2012-11-20 21:25:36 -0500
commit68fa965dd923177eafad49b7a0045fc610917341 (patch)
tree7b717a7dc86097704ca8946c3dcdd74390761367 /drivers/xen/privcmd.c
parentab277bbf662ef17ffb7fd8dd7a462a34e326e492 (diff)
xen/privcmd: Correctly return success from IOCTL_PRIVCMD_MMAPBATCH
This is a regression introduced by ceb90fa0 (xen/privcmd: add PRIVCMD_MMAPBATCH_V2 ioctl). It broke xentrace as it used xc_map_foreign() instead of xc_map_foreign_bulk(). Most code-paths prefer the MMAPBATCH_V2, so this wasn't very obvious that it broke. The return value is set early on to -EINVAL, and if all goes well, the "set top bits of the MFN's" never gets called, so the return value is still EINVAL when the function gets to the end, causing the caller to think it went wrong (which it didn't!) Now also including Andres "move the ret = -EINVAL into the error handling path, as this avoids other similar errors in future. Signed-off-by: Mats Petersson <mats.petersson@citrix.com> Acked-by: Andres Lagar-Cavilla <andres@lagarcavilla.org> Acked-by: David Vrabel <david.vrabel@citrix.com> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Diffstat (limited to 'drivers/xen/privcmd.c')
-rw-r--r--drivers/xen/privcmd.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/drivers/xen/privcmd.c b/drivers/xen/privcmd.c
index 8adb9cc267f9..71f5c459b088 100644
--- a/drivers/xen/privcmd.c
+++ b/drivers/xen/privcmd.c
@@ -361,13 +361,13 @@ static long privcmd_ioctl_mmap_batch(void __user *udata, int version)
361 down_write(&mm->mmap_sem); 361 down_write(&mm->mmap_sem);
362 362
363 vma = find_vma(mm, m.addr); 363 vma = find_vma(mm, m.addr);
364 ret = -EINVAL;
365 if (!vma || 364 if (!vma ||
366 vma->vm_ops != &privcmd_vm_ops || 365 vma->vm_ops != &privcmd_vm_ops ||
367 (m.addr != vma->vm_start) || 366 (m.addr != vma->vm_start) ||
368 ((m.addr + (nr_pages << PAGE_SHIFT)) != vma->vm_end) || 367 ((m.addr + (nr_pages << PAGE_SHIFT)) != vma->vm_end) ||
369 !privcmd_enforce_singleshot_mapping(vma)) { 368 !privcmd_enforce_singleshot_mapping(vma)) {
370 up_write(&mm->mmap_sem); 369 up_write(&mm->mmap_sem);
370 ret = -EINVAL;
371 goto out; 371 goto out;
372 } 372 }
373 373
@@ -383,12 +383,16 @@ static long privcmd_ioctl_mmap_batch(void __user *udata, int version)
383 383
384 up_write(&mm->mmap_sem); 384 up_write(&mm->mmap_sem);
385 385
386 if (state.global_error && (version == 1)) { 386 if (version == 1) {
387 /* Write back errors in second pass. */ 387 if (state.global_error) {
388 state.user_mfn = (xen_pfn_t *)m.arr; 388 /* Write back errors in second pass. */
389 state.err = err_array; 389 state.user_mfn = (xen_pfn_t *)m.arr;
390 ret = traverse_pages(m.num, sizeof(xen_pfn_t), 390 state.err = err_array;
391 &pagelist, mmap_return_errors_v1, &state); 391 ret = traverse_pages(m.num, sizeof(xen_pfn_t),
392 &pagelist, mmap_return_errors_v1, &state);
393 } else
394 ret = 0;
395
392 } else if (version == 2) { 396 } else if (version == 2) {
393 ret = __copy_to_user(m.err, err_array, m.num * sizeof(int)); 397 ret = __copy_to_user(m.err, err_array, m.num * sizeof(int));
394 if (ret) 398 if (ret)