On Tue, Feb 28, 2017 at 12:51:25PM +0000, Ian Abbott wrote:
> Valid latency timer values are between 1 ms and 255 ms in 1 ms steps.
> The store function for the "latency_timer" device attribute currently
> allows any value, although only the lower 8-bits will be written to the
> latency timer.  Return an error for out-of-range values.

And in fact, 0 is currently used (and accepted by the device) if a
negative value is provided.

> Signed-off-by: Ian Abbott <abbo...@mev.co.uk>
> ---
>  drivers/usb/serial/ftdi_sio.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
> index a1b90f4184a7..2da99875cecb 100644
> --- a/drivers/usb/serial/ftdi_sio.c
> +++ b/drivers/usb/serial/ftdi_sio.c
> @@ -1716,6 +1716,9 @@ static ssize_t latency_timer_store(struct device *dev,
>       int v = simple_strtoul(valbuf, NULL, 10);
>       int rv;
>  
> +     if (v < 1 || v > 255)
> +             return -EINVAL;
> +

We probably still need to accept 0 here, which seems to give a timer of
1 ms, as someone may be relying on that behaviour already.

>       priv->latency = v;
>       rv = write_latency_timer(port);
>       if (rv < 0)

Johan
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to