]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] Reintroduce proper returning of -EFAULT to hiddev.c
authorVojtech Pavlik <vojtech@suse.cz>
Mon, 15 Jul 2002 10:18:59 +0000 (03:18 -0700)
committerVojtech Pavlik <vojtech@suse.cz>
Mon, 15 Jul 2002 10:18:59 +0000 (03:18 -0700)
One of my earlier patches backed out a change that fixed all
copy_to_user calls to properly return -EFAULT if needed. This puts the
change back in.

drivers/usb/input/hiddev.c

index 8b5cd439eee774771a26f7a72f29cbf52ab5d12b..8ac1b9111145a9e75a864f2b936523f1e1f55319 100644 (file)
@@ -399,10 +399,12 @@ static int hiddev_ioctl(struct inode *inode, struct file *file, unsigned int cmd
                dinfo.product = dev->descriptor.idProduct;
                dinfo.version = dev->descriptor.bcdDevice;
                dinfo.num_applications = hid->maxapplication;
-               return copy_to_user((void *) arg, &dinfo, sizeof(dinfo));
+               if (copy_to_user((void *) arg, &dinfo, sizeof(dinfo)))
+                       return -EFAULT;
 
        case HIDIOCGFLAG:
-               return put_user(list->flags, (int *) arg);
+               if (put_user(list->flags, (int *) arg))
+                       return -EFAULT;
 
        case HIDIOCSFLAG:
                {
@@ -488,7 +490,8 @@ static int hiddev_ioctl(struct inode *inode, struct file *file, unsigned int cmd
 
                rinfo.num_fields = report->maxfield;
 
-               return copy_to_user((void *) arg, &rinfo, sizeof(rinfo));
+               if (copy_to_user((void *) arg, &rinfo, sizeof(rinfo)))
+                       return -EFAULT;
 
        case HIDIOCGFIELDINFO:
                if (copy_from_user(&finfo, (void *) arg, sizeof(finfo)))
@@ -518,7 +521,8 @@ static int hiddev_ioctl(struct inode *inode, struct file *file, unsigned int cmd
                finfo.unit_exponent = field->unit_exponent;
                finfo.unit = field->unit;
 
-               return copy_to_user((void *) arg, &finfo, sizeof(finfo));
+               if (copy_to_user((void *) arg, &finfo, sizeof(finfo)))
+                       return -EFAULT;
 
        case HIDIOCGUCODE:
                if (copy_from_user(&uref, (void *) arg, sizeof(uref)))
@@ -538,7 +542,8 @@ static int hiddev_ioctl(struct inode *inode, struct file *file, unsigned int cmd
 
                uref.usage_code = field->usage[uref.usage_index].hid;
 
-               return copy_to_user((void *) arg, &uref, sizeof(uref));
+               if (copy_to_user((void *) arg, &uref, sizeof(uref)))
+                       return -EFAULT;
 
        case HIDIOCGUSAGE:
        case HIDIOCSUSAGE:
@@ -570,7 +575,8 @@ static int hiddev_ioctl(struct inode *inode, struct file *file, unsigned int cmd
                switch (cmd) {
                        case HIDIOCGUSAGE:
                                uref.value = field->value[uref.usage_index];
-                               return copy_to_user((void *) arg, &uref, sizeof(uref));
+                               if (copy_to_user((void *) arg, &uref, sizeof(uref)))
+                                       return -EFAULT;
                                return 0;
 
                        case HIDIOCSUSAGE: