xen/privcmd: return -EFAULT on error
authorDan Carpenter <dan.carpenter@oracle.com>
Sat, 8 Sep 2012 09:57:35 +0000 (12:57 +0300)
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Mon, 10 Sep 2012 19:34:56 +0000 (15:34 -0400)
__copy_to_user() returns the number of bytes remaining to be copied but
we want to return a negative error code here.

Acked-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
drivers/xen/privcmd.c

index 3b162c656205c851f8cf83788db4c9066eba04fa..ef6389580b8c78dd30a8c7738098c51b6ef3133a 100644 (file)
@@ -389,8 +389,11 @@ static long privcmd_ioctl_mmap_batch(void __user *udata, int version)
                state.err      = err_array;
                ret = traverse_pages(m.num, sizeof(xen_pfn_t),
                                     &pagelist, mmap_return_errors_v1, &state);
-       } else if (version == 2)
+       } else if (version == 2) {
                ret = __copy_to_user(m.err, err_array, m.num * sizeof(int));
+               if (ret)
+                       ret = -EFAULT;
+       }
 
        /* If we have not had any EFAULT-like global errors then set the global
         * error to -ENOENT if necessary. */