xen-gntdev: return -EFAULT on copy_to_user failure
authorDan Carpenter <error27@gmail.com>
Sat, 19 Mar 2011 05:44:34 +0000 (08:44 +0300)
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Thu, 24 Mar 2011 14:32:44 +0000 (10:32 -0400)
copy_to_user() returns the amount of data remaining to be copied.  We
want to return a negative error code here.  The upper layers just
call WARN_ON() if we return non-zero so this doesn't change the
behavior.  But returning -EFAULT is still cleaner.

Signed-off-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
drivers/xen/gntdev.c

index 017ce600fbc65b43438d6163130b7402bb3eae3c..00b3accc43eefe6b8840aba24404ac33472c3dd6 100644 (file)
@@ -273,7 +273,7 @@ static int __unmap_grant_pages(struct grant_map *map, int offset, int pages)
                                map->vma->vm_start + map->notify.addr;
                        err = copy_to_user(tmp, &err, 1);
                        if (err)
-                               return err;
+                               return -EFAULT;
                        map->notify.flags &= ~UNMAP_NOTIFY_CLEAR_BYTE;
                } else if (pgno >= offset && pgno < offset + pages) {
                        uint8_t *tmp = kmap(map->pages[pgno]);