On 02/03/17 14:22, Johan Hovold wrote:
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.
Yes, although for the same reason that writing the value 'foo' to the
"latency_timer" device attribute results in 0 being used!
Signed-off-by: Ian Abbott <abbotti@xxxxxxxxx>
---
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.
Yes, I just partially confirmed that 0 gives a short latency timeout
like 1, although I never measured it accurately. (I only judged it from
responsiveness of typed characters being echoed back through a serial
loop-back connector.)
I'll fix that in v2 patch series.
priv->latency = v;
rv = write_latency_timer(port);
if (rv < 0)
Johan
--
-=( Ian Abbott @ MEV Ltd. E-mail: <abbotti@xxxxxxxxx> )=-
-=( Web: http://www.mev.co.uk/ )=-
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html