Commit 793fb491 authored by Vojtech Pavlik's avatar Vojtech Pavlik

[PATCH] Reintroduce proper returning of -EFAULT to hiddev.c

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.
parent b24be862
......@@ -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:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment