aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/misc
diff options
context:
space:
mode:
authorBenjamin Tisssoires <benjamin.tissoires@redhat.com>2014-01-30 20:16:36 -0500
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2014-01-30 20:30:57 -0500
commit9d51e801dba0c79ae979ef2f6928e402eb41009b (patch)
tree038314e23edf877a325746a851a094c4e1ae79bf /drivers/input/misc
parent6f2e6c9b451b907b693b7fe3db3792e57796ffea (diff)
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: Benjamin Tisssoires <benjamin.tissoires@redhat.com> Reviewed-by: David Herrmann <dh.herrmann@gmail.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input/misc')
-rw-r--r--drivers/input/misc/uinput.c56
1 files changed, 27 insertions, 29 deletions
diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c
index 772835938a52..d8ae08d12abf 100644
--- a/drivers/input/misc/uinput.c
+++ b/drivers/input/misc/uinput.c
@@ -693,51 +693,51 @@ static long uinput_ioctl_handler(struct file *file, unsigned int cmd,
693 switch (cmd) { 693 switch (cmd) {
694 case UI_DEV_CREATE: 694 case UI_DEV_CREATE:
695 retval = uinput_create_device(udev); 695 retval = uinput_create_device(udev);
696 break; 696 goto out;
697 697
698 case UI_DEV_DESTROY: 698 case UI_DEV_DESTROY:
699 uinput_destroy_device(udev); 699 uinput_destroy_device(udev);
700 break; 700 goto out;
701 701
702 case UI_SET_EVBIT: 702 case UI_SET_EVBIT:
703 retval = uinput_set_bit(arg, evbit, EV_MAX); 703 retval = uinput_set_bit(arg, evbit, EV_MAX);
704 break; 704 goto out;
705 705
706 case UI_SET_KEYBIT: 706 case UI_SET_KEYBIT:
707 retval = uinput_set_bit(arg, keybit, KEY_MAX); 707 retval = uinput_set_bit(arg, keybit, KEY_MAX);
708 break; 708 goto out;
709 709
710 case UI_SET_RELBIT: 710 case UI_SET_RELBIT:
711 retval = uinput_set_bit(arg, relbit, REL_MAX); 711 retval = uinput_set_bit(arg, relbit, REL_MAX);
712 break; 712 goto out;
713 713
714 case UI_SET_ABSBIT: 714 case UI_SET_ABSBIT:
715 retval = uinput_set_bit(arg, absbit, ABS_MAX); 715 retval = uinput_set_bit(arg, absbit, ABS_MAX);
716 break; 716 goto out;
717 717
718 case UI_SET_MSCBIT: 718 case UI_SET_MSCBIT:
719 retval = uinput_set_bit(arg, mscbit, MSC_MAX); 719 retval = uinput_set_bit(arg, mscbit, MSC_MAX);
720 break; 720 goto out;
721 721
722 case UI_SET_LEDBIT: 722 case UI_SET_LEDBIT:
723 retval = uinput_set_bit(arg, ledbit, LED_MAX); 723 retval = uinput_set_bit(arg, ledbit, LED_MAX);
724 break; 724 goto out;
725 725
726 case UI_SET_SNDBIT: 726 case UI_SET_SNDBIT:
727 retval = uinput_set_bit(arg, sndbit, SND_MAX); 727 retval = uinput_set_bit(arg, sndbit, SND_MAX);
728 break; 728 goto out;
729 729
730 case UI_SET_FFBIT: 730 case UI_SET_FFBIT:
731 retval = uinput_set_bit(arg, ffbit, FF_MAX); 731 retval = uinput_set_bit(arg, ffbit, FF_MAX);
732 break; 732 goto out;
733 733
734 case UI_SET_SWBIT: 734 case UI_SET_SWBIT:
735 retval = uinput_set_bit(arg, swbit, SW_MAX); 735 retval = uinput_set_bit(arg, swbit, SW_MAX);
736 break; 736 goto out;
737 737
738 case UI_SET_PROPBIT: 738 case UI_SET_PROPBIT:
739 retval = uinput_set_bit(arg, propbit, INPUT_PROP_MAX); 739 retval = uinput_set_bit(arg, propbit, INPUT_PROP_MAX);
740 break; 740 goto out;
741 741
742 case UI_SET_PHYS: 742 case UI_SET_PHYS:
743 if (udev->state == UIST_CREATED) { 743 if (udev->state == UIST_CREATED) {
@@ -753,18 +753,18 @@ static long uinput_ioctl_handler(struct file *file, unsigned int cmd,
753 753
754 kfree(udev->dev->phys); 754 kfree(udev->dev->phys);
755 udev->dev->phys = phys; 755 udev->dev->phys = phys;
756 break; 756 goto out;
757 757
758 case UI_BEGIN_FF_UPLOAD: 758 case UI_BEGIN_FF_UPLOAD:
759 retval = uinput_ff_upload_from_user(p, &ff_up); 759 retval = uinput_ff_upload_from_user(p, &ff_up);
760 if (retval) 760 if (retval)
761 break; 761 goto out;
762 762
763 req = uinput_request_find(udev, ff_up.request_id); 763 req = uinput_request_find(udev, ff_up.request_id);
764 if (!req || req->code != UI_FF_UPLOAD || 764 if (!req || req->code != UI_FF_UPLOAD ||
765 !req->u.upload.effect) { 765 !req->u.upload.effect) {
766 retval = -EINVAL; 766 retval = -EINVAL;
767 break; 767 goto out;
768 } 768 }
769 769
770 ff_up.retval = 0; 770 ff_up.retval = 0;
@@ -775,65 +775,63 @@ static long uinput_ioctl_handler(struct file *file, unsigned int cmd,
775 memset(&ff_up.old, 0, sizeof(struct ff_effect)); 775 memset(&ff_up.old, 0, sizeof(struct ff_effect));
776 776
777 retval = uinput_ff_upload_to_user(p, &ff_up); 777 retval = uinput_ff_upload_to_user(p, &ff_up);
778 break; 778 goto out;
779 779
780 case UI_BEGIN_FF_ERASE: 780 case UI_BEGIN_FF_ERASE:
781 if (copy_from_user(&ff_erase, p, sizeof(ff_erase))) { 781 if (copy_from_user(&ff_erase, p, sizeof(ff_erase))) {
782 retval = -EFAULT; 782 retval = -EFAULT;
783 break; 783 goto out;
784 } 784 }
785 785
786 req = uinput_request_find(udev, ff_erase.request_id); 786 req = uinput_request_find(udev, ff_erase.request_id);
787 if (!req || req->code != UI_FF_ERASE) { 787 if (!req || req->code != UI_FF_ERASE) {
788 retval = -EINVAL; 788 retval = -EINVAL;
789 break; 789 goto out;
790 } 790 }
791 791
792 ff_erase.retval = 0; 792 ff_erase.retval = 0;
793 ff_erase.effect_id = req->u.effect_id; 793 ff_erase.effect_id = req->u.effect_id;
794 if (copy_to_user(p, &ff_erase, sizeof(ff_erase))) { 794 if (copy_to_user(p, &ff_erase, sizeof(ff_erase))) {
795 retval = -EFAULT; 795 retval = -EFAULT;
796 break; 796 goto out;
797 } 797 }
798 798
799 break; 799 goto out;
800 800
801 case UI_END_FF_UPLOAD: 801 case UI_END_FF_UPLOAD:
802 retval = uinput_ff_upload_from_user(p, &ff_up); 802 retval = uinput_ff_upload_from_user(p, &ff_up);
803 if (retval) 803 if (retval)
804 break; 804 goto out;
805 805
806 req = uinput_request_find(udev, ff_up.request_id); 806 req = uinput_request_find(udev, ff_up.request_id);
807 if (!req || req->code != UI_FF_UPLOAD || 807 if (!req || req->code != UI_FF_UPLOAD ||
808 !req->u.upload.effect) { 808 !req->u.upload.effect) {
809 retval = -EINVAL; 809 retval = -EINVAL;
810 break; 810 goto out;
811 } 811 }
812 812
813 req->retval = ff_up.retval; 813 req->retval = ff_up.retval;
814 uinput_request_done(udev, req); 814 uinput_request_done(udev, req);
815 break; 815 goto out;
816 816
817 case UI_END_FF_ERASE: 817 case UI_END_FF_ERASE:
818 if (copy_from_user(&ff_erase, p, sizeof(ff_erase))) { 818 if (copy_from_user(&ff_erase, p, sizeof(ff_erase))) {
819 retval = -EFAULT; 819 retval = -EFAULT;
820 break; 820 goto out;
821 } 821 }
822 822
823 req = uinput_request_find(udev, ff_erase.request_id); 823 req = uinput_request_find(udev, ff_erase.request_id);
824 if (!req || req->code != UI_FF_ERASE) { 824 if (!req || req->code != UI_FF_ERASE) {
825 retval = -EINVAL; 825 retval = -EINVAL;
826 break; 826 goto out;
827 } 827 }
828 828
829 req->retval = ff_erase.retval; 829 req->retval = ff_erase.retval;
830 uinput_request_done(udev, req); 830 uinput_request_done(udev, req);
831 break; 831 goto out;
832
833 default:
834 retval = -EINVAL;
835 } 832 }
836 833
834 retval = -EINVAL;
837 out: 835 out:
838 mutex_unlock(&udev->mutex); 836 mutex_unlock(&udev->mutex);
839 return retval; 837 return retval;