Commit 9d51e801 authored by Benjamin Tisssoires's avatar Benjamin Tisssoires Committed by Dmitry Torokhov

Input: uinput - breaks by goto out in uinput_ioctl_handler

The current implementation prevents us to add variable-length ioctl.
Use a bunch of gotos instead of break to allow us to do so.

No functional changes.
Signed-off-by: default avatarBenjamin Tisssoires <benjamin.tissoires@redhat.com>
Reviewed-by: default avatarDavid Herrmann <dh.herrmann@gmail.com>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 6f2e6c9b
...@@ -693,51 +693,51 @@ static long uinput_ioctl_handler(struct file *file, unsigned int cmd, ...@@ -693,51 +693,51 @@ static long uinput_ioctl_handler(struct file *file, unsigned int cmd,
switch (cmd) { switch (cmd) {
case UI_DEV_CREATE: case UI_DEV_CREATE:
retval = uinput_create_device(udev); retval = uinput_create_device(udev);
break; goto out;
case UI_DEV_DESTROY: case UI_DEV_DESTROY:
uinput_destroy_device(udev); uinput_destroy_device(udev);
break; goto out;
case UI_SET_EVBIT: case UI_SET_EVBIT:
retval = uinput_set_bit(arg, evbit, EV_MAX); retval = uinput_set_bit(arg, evbit, EV_MAX);
break; goto out;
case UI_SET_KEYBIT: case UI_SET_KEYBIT:
retval = uinput_set_bit(arg, keybit, KEY_MAX); retval = uinput_set_bit(arg, keybit, KEY_MAX);
break; goto out;
case UI_SET_RELBIT: case UI_SET_RELBIT:
retval = uinput_set_bit(arg, relbit, REL_MAX); retval = uinput_set_bit(arg, relbit, REL_MAX);
break; goto out;
case UI_SET_ABSBIT: case UI_SET_ABSBIT:
retval = uinput_set_bit(arg, absbit, ABS_MAX); retval = uinput_set_bit(arg, absbit, ABS_MAX);
break; goto out;
case UI_SET_MSCBIT: case UI_SET_MSCBIT:
retval = uinput_set_bit(arg, mscbit, MSC_MAX); retval = uinput_set_bit(arg, mscbit, MSC_MAX);
break; goto out;
case UI_SET_LEDBIT: case UI_SET_LEDBIT:
retval = uinput_set_bit(arg, ledbit, LED_MAX); retval = uinput_set_bit(arg, ledbit, LED_MAX);
break; goto out;
case UI_SET_SNDBIT: case UI_SET_SNDBIT:
retval = uinput_set_bit(arg, sndbit, SND_MAX); retval = uinput_set_bit(arg, sndbit, SND_MAX);
break; goto out;
case UI_SET_FFBIT: case UI_SET_FFBIT:
retval = uinput_set_bit(arg, ffbit, FF_MAX); retval = uinput_set_bit(arg, ffbit, FF_MAX);
break; goto out;
case UI_SET_SWBIT: case UI_SET_SWBIT:
retval = uinput_set_bit(arg, swbit, SW_MAX); retval = uinput_set_bit(arg, swbit, SW_MAX);
break; goto out;
case UI_SET_PROPBIT: case UI_SET_PROPBIT:
retval = uinput_set_bit(arg, propbit, INPUT_PROP_MAX); retval = uinput_set_bit(arg, propbit, INPUT_PROP_MAX);
break; goto out;
case UI_SET_PHYS: case UI_SET_PHYS:
if (udev->state == UIST_CREATED) { if (udev->state == UIST_CREATED) {
...@@ -753,18 +753,18 @@ static long uinput_ioctl_handler(struct file *file, unsigned int cmd, ...@@ -753,18 +753,18 @@ static long uinput_ioctl_handler(struct file *file, unsigned int cmd,
kfree(udev->dev->phys); kfree(udev->dev->phys);
udev->dev->phys = phys; udev->dev->phys = phys;
break; goto out;
case UI_BEGIN_FF_UPLOAD: case UI_BEGIN_FF_UPLOAD:
retval = uinput_ff_upload_from_user(p, &ff_up); retval = uinput_ff_upload_from_user(p, &ff_up);
if (retval) if (retval)
break; goto out;
req = uinput_request_find(udev, ff_up.request_id); req = uinput_request_find(udev, ff_up.request_id);
if (!req || req->code != UI_FF_UPLOAD || if (!req || req->code != UI_FF_UPLOAD ||
!req->u.upload.effect) { !req->u.upload.effect) {
retval = -EINVAL; retval = -EINVAL;
break; goto out;
} }
ff_up.retval = 0; ff_up.retval = 0;
...@@ -775,65 +775,63 @@ static long uinput_ioctl_handler(struct file *file, unsigned int cmd, ...@@ -775,65 +775,63 @@ static long uinput_ioctl_handler(struct file *file, unsigned int cmd,
memset(&ff_up.old, 0, sizeof(struct ff_effect)); memset(&ff_up.old, 0, sizeof(struct ff_effect));
retval = uinput_ff_upload_to_user(p, &ff_up); retval = uinput_ff_upload_to_user(p, &ff_up);
break; goto out;
case UI_BEGIN_FF_ERASE: case UI_BEGIN_FF_ERASE:
if (copy_from_user(&ff_erase, p, sizeof(ff_erase))) { if (copy_from_user(&ff_erase, p, sizeof(ff_erase))) {
retval = -EFAULT; retval = -EFAULT;
break; goto out;
} }
req = uinput_request_find(udev, ff_erase.request_id); req = uinput_request_find(udev, ff_erase.request_id);
if (!req || req->code != UI_FF_ERASE) { if (!req || req->code != UI_FF_ERASE) {
retval = -EINVAL; retval = -EINVAL;
break; goto out;
} }
ff_erase.retval = 0; ff_erase.retval = 0;
ff_erase.effect_id = req->u.effect_id; ff_erase.effect_id = req->u.effect_id;
if (copy_to_user(p, &ff_erase, sizeof(ff_erase))) { if (copy_to_user(p, &ff_erase, sizeof(ff_erase))) {
retval = -EFAULT; retval = -EFAULT;
break; goto out;
} }
break; goto out;
case UI_END_FF_UPLOAD: case UI_END_FF_UPLOAD:
retval = uinput_ff_upload_from_user(p, &ff_up); retval = uinput_ff_upload_from_user(p, &ff_up);
if (retval) if (retval)
break; goto out;
req = uinput_request_find(udev, ff_up.request_id); req = uinput_request_find(udev, ff_up.request_id);
if (!req || req->code != UI_FF_UPLOAD || if (!req || req->code != UI_FF_UPLOAD ||
!req->u.upload.effect) { !req->u.upload.effect) {
retval = -EINVAL; retval = -EINVAL;
break; goto out;
} }
req->retval = ff_up.retval; req->retval = ff_up.retval;
uinput_request_done(udev, req); uinput_request_done(udev, req);
break; goto out;
case UI_END_FF_ERASE: case UI_END_FF_ERASE:
if (copy_from_user(&ff_erase, p, sizeof(ff_erase))) { if (copy_from_user(&ff_erase, p, sizeof(ff_erase))) {
retval = -EFAULT; retval = -EFAULT;
break; goto out;
} }
req = uinput_request_find(udev, ff_erase.request_id); req = uinput_request_find(udev, ff_erase.request_id);
if (!req || req->code != UI_FF_ERASE) { if (!req || req->code != UI_FF_ERASE) {
retval = -EINVAL; retval = -EINVAL;
break; goto out;
} }
req->retval = ff_erase.retval; req->retval = ff_erase.retval;
uinput_request_done(udev, req); uinput_request_done(udev, req);
break; goto out;
default:
retval = -EINVAL;
} }
retval = -EINVAL;
out: out:
mutex_unlock(&udev->mutex); mutex_unlock(&udev->mutex);
return retval; return retval;
......
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