Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1255269

Re: [PATCH v3] Input: uinput - add new UINPUT_DEV_SETUP and UI_ABS_SETUP ioctl

From Dmitry Torokhov <dmitry.torokhov@gmail.com>
Newsgroups linux.kernel
Subject Re: [PATCH v3] Input: uinput - add new UINPUT_DEV_SETUP and UI_ABS_SETUP ioctl
Date 2015-10-25 04:10 +0100
Message-ID <qnjR0-37Z-3@gated-at.bofh.it> (permalink)
References <q1ob0-1NF-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Hi Benjamin,

On Tue, Aug 25, 2015 at 11:12:59AM -0400, Benjamin Tissoires wrote:
> +static int uinput_abs_setup(struct uinput_device *udev,
> +			    struct uinput_setup __user *arg, size_t size)
> +{
> +	struct uinput_abs_setup setup = {};
> +	struct input_dev *dev;
> +
> +	if (size > sizeof(setup))
> +		return -E2BIG;
> +	if (udev->state == UIST_CREATED)
> +		return -EINVAL;
> +	if (copy_from_user(&setup, arg, size))
> +		return -EFAULT;
> +	if (setup.code > ABS_MAX)
> +		return -ERANGE;
> +
> +	dev = udev->dev;
> +
> +	input_alloc_absinfo(dev);
> +	if (!dev->absinfo)
> +		return -ENOMEM;
> +
> +	set_bit(setup.code, dev->absbit);
> +	dev->absinfo[setup.code] = setup.absinfo;
> +
> +	/*
> +	 * We restore the state to UIST_NEW_DEVICE because the user has to call
> +	 * UI_DEV_SETUP in the last place before UI_DEV_CREATE to check the
> +	 * validity of the absbits.
> +	 */

Do we have to be this strict? It seems to me that with the new IOCTLs
you naturally want to use the new ioctl to setup the device, then adjust
various axes and bits and then validate everything.

Thanks.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: [PATCH v3] Input: uinput - add new UINPUT_DEV_SETUP and  UI_ABS_SETUP ioctl Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2015-10-25 04:10 +0100
  Re: [PATCH v3] Input: uinput - add new UINPUT_DEV_SETUP and  UI_ABS_SETUP ioctl David Herrmann <dh.herrmann@gmail.com> - 2015-10-25 10:40 +0100
    Re: [PATCH v3] Input: uinput - add new UINPUT_DEV_SETUP and  UI_ABS_SETUP ioctl Benjamin Tissoires <benjamin.tissoires@redhat.com> - 2015-10-28 16:20 +0100

csiph-web