Input-polldev:Check poll_interval range while registering input device
Subsystems (2)
PATCH 1/1 Input-polldev:Check poll_interval range while registering input device
Added check for poll_interval range in input_register_polled_device function similar to input_polldev_set_poll function.
--- drivers/input/input-polldev.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/input/input-polldev.c +6 -0
@@ -309,6 +309,12 @@ int input_register_polled_device(struct input_polled_dev *dev)input_set_drvdata (input, dev);INIT_DELAYED_WORK (&dev->work, input_polled_device_work); + +if (dev->poll_interval > dev->poll_interval_max || + dev->poll_interval < dev->poll_interval_min) { +pr_err ("Poll interval Range incorrect\n" ); +return -EINVAL ; + }if (!dev->poll_interval) dev->poll_interval =500 ;
Signature · 6 lines
1.7.9.5 --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus
Dmitry Torokhov
maintainerHi Anshul,
Quoted 13 lines · Anshul Garg
Added check for
poll_intervalrange ininput_register_polled_devicefunction similar toinput_polldev_set_pollfunction.Signed-off-by Anshul Garg <[email protected]>--- drivers/input/input-polldev.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/input/input-polldev.c +0
-0
drivers/input/input-polldev.c int input_register_polled_device(struct input_polled_dev *dev) · line 317
Quoted 9 lines
drivers/input/input-polldev.c +6
-0@@ -309,6 +309,12 @@ int input_register_polled_device(struct input_polled_dev *dev)input_set_drvdata (input, dev);INIT_DELAYED_WORK (&dev->work, input_polled_device_work); + +if (dev->poll_interval > dev->poll_interval_max || + dev->poll_interval < dev->poll_interval_min) { +pr_err ("Poll interval Range incorrect\n" ); +return -EINVAL ; + }
What driver was this change tested with?
Thanks.
Signature · 1 line
Dmitry
Hi Mr. Dmitry
,
Quoted 17 lines · Dmitry Torokhov
Hi Anshul,
Quoted 14 lines · Anshul Garg
Added check for
poll_intervalrange ininput_register_polled_devicefunction similar toinput_polldev_set_pollfunction.Signed-off-by Anshul Garg <[email protected]>--- drivers/input/input-polldev.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/input/input-polldev.c +0
-0@@ -309,6 +309,12 @@ int input_register_polled_device(struct input_polled_dev *dev)
Quoted 10 lines
drivers/input/input-polldev.c int input_register_polled_device(struct input_polled_dev *dev) · line 317
Quoted 8 lines
drivers/input/input-polldev.c +6
-0input_set_drvdata (input, dev);INIT_DELAYED_WORK (&dev->work, input_polled_device_work); + +if (dev->poll_interval > dev->poll_interval_max || + dev->poll_interval < dev->poll_interval_min) { +pr_err ("Poll interval Range incorrect\n" ); +return -EINVAL ; + }What driver was this change tested with?
I have not checked this change for any driver.
This check is useful if some input driver is setting outofrange poll_interval value
i.e. not in range between min,max. Similar to input_polldev_set_poll which does this
when user space tries to change poll interval
Thanks
Anshul Garg
Quoted 5 lines
Thanks.
--
Dmitry
Dmitry Torokhov
maintainerQuoted 34 lines · Anshul Garg
Hi Mr. Dmitry
,Quoted 17 lines · Dmitry Torokhov
Hi Anshul,
Quoted 14 lines · Anshul Garg
Added check for
poll_intervalrange ininput_register_polled_devicefunction similar toinput_polldev_set_pollfunction.Signed-off-by Anshul Garg <[email protected]>--- drivers/input/input-polldev.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/input/input-polldev.c +0
-0@@ -309,6 +309,12 @@ int input_register_polled_device(struct input_polled_dev *dev)Quoted 10 lines
drivers/input/input-polldev.c int input_register_polled_device(struct input_polled_dev *dev) · line 317
Quoted 8 lines
drivers/input/input-polldev.c +6
-0input_set_drvdata (input, dev);INIT_DELAYED_WORK (&dev->work, input_polled_device_work); + +if (dev->poll_interval > dev->poll_interval_max || + dev->poll_interval < dev->poll_interval_min) { +pr_err ("Poll interval Range incorrect\n" ); +return -EINVAL ; + }What driver was this change tested with?
Quoted 2 lines
I have not checked this change for any driver.
Yes, I know that you did not test it because if you would have tested it you would have noticed that it breaks existing devices, since hardly any of them set dev->poll_interval_max and instead rely on the polldev code to apply reasonable defaults.
There have been a few patches that had errors that would have been easily caught if you tested the changes. Please next time you submit a patch mention how you tested it to make sure it works as intended.
Thanks.
Signature · 1 line
Dmitry
drivers/input/input-polldev.c int input_register_polled_device(struct input_polled_dev *dev) · line 320
Quoted 8 lines · Anshul Garg
drivers/input/input-polldev.c +5
-0+if (dev->poll_interval > dev->poll_interval_max || + dev->poll_interval < dev->poll_interval_min) { +pr_err ("Poll interval Range incorrect\n" ); +return -EINVAL ; + }if (!dev->poll_interval) dev->poll_interval =500 ;
So priviously, if poll_interval was 0 you got a sane default of 500, and now you get -EINVAL.
Is this really useful and correct, and nobody using it is passing 0?
regards
Marcus