Skip to contentSkip to conversation

xen-gntdev: return -EFAULT on copy_to_user failure

PATCH In review Dan Carpenter 2 participants 3 messages Mar 19, 2011 – Mar 25, 2011

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 xen-gntdev: return -EFAULT on copy_to_user failure

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.

drivers/xen/gntdev.c +1 -1
index 017ce60..b0f9e8f 100644
@@ -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]);
#1 lore raw

Re: [Xen-devel] [patch 1/2] xen-gntdev: return -EFAULT on

Quoted 4 lines · Dan Carpenter

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.

Thank you. Will put it on rc1 train.

Quoted 21 lines
drivers/xen/gntdev.c +1 -1
index 017ce60..b0f9e8f 100644
@@ -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]);

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#2 lore raw
In reply to Dan Carpenter
Quoted 4 lines · Dan Carpenter

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.

Thank you. Will put it on rc1 train.

Quoted 21 lines
drivers/xen/gntdev.c +1 -1
index 017ce60..b0f9e8f 100644
@@ -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]);

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel