linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Input-polldev:Check poll_interval range while registering input device
@ 2015-07-14 13:25 Anshul Garg
  0 siblings, 0 replies; 6+ messages in thread
From: Anshul Garg @ 2015-07-14 13:25 UTC (permalink / raw)
  To: dmitry.torokhov, linux-input; +Cc: aksgarg1989

Added check for poll_interval range in input_register_polled_device
function similar to input_polldev_set_poll function.

Signed-off-by: Anshul Garg <aksgarg1989@gmail.com>
---
 drivers/input/input-polldev.c |    6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/input/input-polldev.c b/drivers/input/input-polldev.c
index 3664f81..0e88a9e 100644
--- a/drivers/input/input-polldev.c
+++ b/drivers/input/input-polldev.c
@@ -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;
-- 
1.7.9.5


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH] Input-polldev:Check poll_interval range while registering input device
@ 2015-07-16 17:57 Anshul Garg
  2015-07-16 19:35 ` Dmitry Torokhov
  2015-07-17 20:29 ` Marcus Overhagen
  0 siblings, 2 replies; 6+ messages in thread
From: Anshul Garg @ 2015-07-16 17:57 UTC (permalink / raw)
  To: dmitry.torokhov, linux-input; +Cc: aksgarg1989

Added check for poll_interval range in input_register_polled_device
function similar to input_polldev_set_poll function.

Signed-off-by: Anshul Garg <aksgarg1989@gmail.com>
---
 drivers/input/input-polldev.c |    6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/input/input-polldev.c b/drivers/input/input-polldev.c
index 3664f81..0e88a9e 100644
--- a/drivers/input/input-polldev.c
+++ b/drivers/input/input-polldev.c
@@ -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;
-- 
1.7.9.5


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] Input-polldev:Check poll_interval range while registering input device
  2015-07-16 17:57 Anshul Garg
@ 2015-07-16 19:35 ` Dmitry Torokhov
  2015-07-17 13:41   ` Anshul Garg
  2015-07-17 20:29 ` Marcus Overhagen
  1 sibling, 1 reply; 6+ messages in thread
From: Dmitry Torokhov @ 2015-07-16 19:35 UTC (permalink / raw)
  To: Anshul Garg; +Cc: linux-input

Hi Anshul,

On Thu, Jul 16, 2015 at 10:57:13AM -0700, Anshul Garg wrote:
> Added check for poll_interval range in input_register_polled_device
> function similar to input_polldev_set_poll function.
> 
> Signed-off-by: Anshul Garg <aksgarg1989@gmail.com>
> ---
>  drivers/input/input-polldev.c |    6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/input/input-polldev.c b/drivers/input/input-polldev.c
> index 3664f81..0e88a9e 100644
> --- a/drivers/input/input-polldev.c
> +++ b/drivers/input/input-polldev.c
> @@ -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.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Input-polldev:Check poll_interval range while registering input device
  2015-07-16 19:35 ` Dmitry Torokhov
@ 2015-07-17 13:41   ` Anshul Garg
  2015-07-17 21:29     ` Dmitry Torokhov
  0 siblings, 1 reply; 6+ messages in thread
From: Anshul Garg @ 2015-07-17 13:41 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: linux-input

Hi Mr. Dmitry
,



On Fri, Jul 17, 2015 at 1:05 AM, Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
> Hi Anshul,
>
> On Thu, Jul 16, 2015 at 10:57:13AM -0700, Anshul Garg wrote:
>> Added check for poll_interval range in input_register_polled_device
>> function similar to input_polldev_set_poll function.
>>
>> Signed-off-by: Anshul Garg <aksgarg1989@gmail.com>
>> ---
>>  drivers/input/input-polldev.c |    6 ++++++
>>  1 file changed, 6 insertions(+)
>>
>> diff --git a/drivers/input/input-polldev.c b/drivers/input/input-polldev.c
>> index 3664f81..0e88a9e 100644
>> --- a/drivers/input/input-polldev.c
>> +++ b/drivers/input/input-polldev.c
>> @@ -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?
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
>
> Thanks.
>
> --
> Dmitry

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Input-polldev:Check poll_interval range while registering input device
  2015-07-16 17:57 Anshul Garg
  2015-07-16 19:35 ` Dmitry Torokhov
@ 2015-07-17 20:29 ` Marcus Overhagen
  1 sibling, 0 replies; 6+ messages in thread
From: Marcus Overhagen @ 2015-07-17 20:29 UTC (permalink / raw)
  To: Anshul Garg; +Cc: Dmitry Torokhov, linux-input

On Thu, Jul 16, 2015 at 7:57 PM, Anshul Garg <aksgarg1989@gmail.com> wrote:

> +       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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Input-polldev:Check poll_interval range while registering input device
  2015-07-17 13:41   ` Anshul Garg
@ 2015-07-17 21:29     ` Dmitry Torokhov
  0 siblings, 0 replies; 6+ messages in thread
From: Dmitry Torokhov @ 2015-07-17 21:29 UTC (permalink / raw)
  To: Anshul Garg; +Cc: linux-input

On Fri, Jul 17, 2015 at 07:11:04PM +0530, Anshul Garg wrote:
> Hi Mr. Dmitry
> ,
> 
> 
> 
> On Fri, Jul 17, 2015 at 1:05 AM, Dmitry Torokhov
> <dmitry.torokhov@gmail.com> wrote:
> > Hi Anshul,
> >
> > On Thu, Jul 16, 2015 at 10:57:13AM -0700, Anshul Garg wrote:
> >> Added check for poll_interval range in input_register_polled_device
> >> function similar to input_polldev_set_poll function.
> >>
> >> Signed-off-by: Anshul Garg <aksgarg1989@gmail.com>
> >> ---
> >>  drivers/input/input-polldev.c |    6 ++++++
> >>  1 file changed, 6 insertions(+)
> >>
> >> diff --git a/drivers/input/input-polldev.c b/drivers/input/input-polldev.c
> >> index 3664f81..0e88a9e 100644
> >> --- a/drivers/input/input-polldev.c
> >> +++ b/drivers/input/input-polldev.c
> >> @@ -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?
> 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.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-07-17 21:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-14 13:25 [PATCH] Input-polldev:Check poll_interval range while registering input device Anshul Garg
  -- strict thread matches above, loose matches on Subject: below --
2015-07-16 17:57 Anshul Garg
2015-07-16 19:35 ` Dmitry Torokhov
2015-07-17 13:41   ` Anshul Garg
2015-07-17 21:29     ` Dmitry Torokhov
2015-07-17 20:29 ` Marcus Overhagen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).