Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Benjamin Tisssoires and committed by
Dmitry Torokhov
9d51e801 6f2e6c9b

+27 -29
+27 -29
drivers/input/misc/uinput.c
··· 693 693 switch (cmd) { 694 694 case UI_DEV_CREATE: 695 695 retval = uinput_create_device(udev); 696 - break; 696 + goto out; 697 697 698 698 case UI_DEV_DESTROY: 699 699 uinput_destroy_device(udev); 700 - break; 700 + goto out; 701 701 702 702 case UI_SET_EVBIT: 703 703 retval = uinput_set_bit(arg, evbit, EV_MAX); 704 - break; 704 + goto out; 705 705 706 706 case UI_SET_KEYBIT: 707 707 retval = uinput_set_bit(arg, keybit, KEY_MAX); 708 - break; 708 + goto out; 709 709 710 710 case UI_SET_RELBIT: 711 711 retval = uinput_set_bit(arg, relbit, REL_MAX); 712 - break; 712 + goto out; 713 713 714 714 case UI_SET_ABSBIT: 715 715 retval = uinput_set_bit(arg, absbit, ABS_MAX); 716 - break; 716 + goto out; 717 717 718 718 case UI_SET_MSCBIT: 719 719 retval = uinput_set_bit(arg, mscbit, MSC_MAX); 720 - break; 720 + goto out; 721 721 722 722 case UI_SET_LEDBIT: 723 723 retval = uinput_set_bit(arg, ledbit, LED_MAX); 724 - break; 724 + goto out; 725 725 726 726 case UI_SET_SNDBIT: 727 727 retval = uinput_set_bit(arg, sndbit, SND_MAX); 728 - break; 728 + goto out; 729 729 730 730 case UI_SET_FFBIT: 731 731 retval = uinput_set_bit(arg, ffbit, FF_MAX); 732 - break; 732 + goto out; 733 733 734 734 case UI_SET_SWBIT: 735 735 retval = uinput_set_bit(arg, swbit, SW_MAX); 736 - break; 736 + goto out; 737 737 738 738 case UI_SET_PROPBIT: 739 739 retval = uinput_set_bit(arg, propbit, INPUT_PROP_MAX); 740 - break; 740 + goto out; 741 741 742 742 case UI_SET_PHYS: 743 743 if (udev->state == UIST_CREATED) { ··· 753 753 754 754 kfree(udev->dev->phys); 755 755 udev->dev->phys = phys; 756 - break; 756 + goto out; 757 757 758 758 case UI_BEGIN_FF_UPLOAD: 759 759 retval = uinput_ff_upload_from_user(p, &ff_up); 760 760 if (retval) 761 - break; 761 + goto out; 762 762 763 763 req = uinput_request_find(udev, ff_up.request_id); 764 764 if (!req || req->code != UI_FF_UPLOAD || 765 765 !req->u.upload.effect) { 766 766 retval = -EINVAL; 767 - break; 767 + goto out; 768 768 } 769 769 770 770 ff_up.retval = 0; ··· 775 775 memset(&ff_up.old, 0, sizeof(struct ff_effect)); 776 776 777 777 retval = uinput_ff_upload_to_user(p, &ff_up); 778 - break; 778 + goto out; 779 779 780 780 case UI_BEGIN_FF_ERASE: 781 781 if (copy_from_user(&ff_erase, p, sizeof(ff_erase))) { 782 782 retval = -EFAULT; 783 - break; 783 + goto out; 784 784 } 785 785 786 786 req = uinput_request_find(udev, ff_erase.request_id); 787 787 if (!req || req->code != UI_FF_ERASE) { 788 788 retval = -EINVAL; 789 - break; 789 + goto out; 790 790 } 791 791 792 792 ff_erase.retval = 0; 793 793 ff_erase.effect_id = req->u.effect_id; 794 794 if (copy_to_user(p, &ff_erase, sizeof(ff_erase))) { 795 795 retval = -EFAULT; 796 - break; 796 + goto out; 797 797 } 798 798 799 - break; 799 + goto out; 800 800 801 801 case UI_END_FF_UPLOAD: 802 802 retval = uinput_ff_upload_from_user(p, &ff_up); 803 803 if (retval) 804 - break; 804 + goto out; 805 805 806 806 req = uinput_request_find(udev, ff_up.request_id); 807 807 if (!req || req->code != UI_FF_UPLOAD || 808 808 !req->u.upload.effect) { 809 809 retval = -EINVAL; 810 - break; 810 + goto out; 811 811 } 812 812 813 813 req->retval = ff_up.retval; 814 814 uinput_request_done(udev, req); 815 - break; 815 + goto out; 816 816 817 817 case UI_END_FF_ERASE: 818 818 if (copy_from_user(&ff_erase, p, sizeof(ff_erase))) { 819 819 retval = -EFAULT; 820 - break; 820 + goto out; 821 821 } 822 822 823 823 req = uinput_request_find(udev, ff_erase.request_id); 824 824 if (!req || req->code != UI_FF_ERASE) { 825 825 retval = -EINVAL; 826 - break; 826 + goto out; 827 827 } 828 828 829 829 req->retval = ff_erase.retval; 830 830 uinput_request_done(udev, req); 831 - break; 832 - 833 - default: 834 - retval = -EINVAL; 831 + goto out; 835 832 } 836 833 834 + retval = -EINVAL; 837 835 out: 838 836 mutex_unlock(&udev->mutex); 839 837 return retval;