summaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/ftdi_sio.c
diff options
context:
space:
mode:
authorIan Abbott <abbotti@mev.co.uk>2017-03-08 16:03:00 +0000
committerJohan Hovold <johan@kernel.org>2017-03-13 16:55:41 +0100
commitd0559a2f294c9b50d7795a8362931f0db8953de1 (patch)
tree0c3943246b8cd960371318dcf2bb9130a06feae0 /drivers/usb/serial/ftdi_sio.c
parentdb9240662a44e1b7781c8dbf35631bcec7a369c6 (diff)
downloadop-kernel-dev-d0559a2f294c9b50d7795a8362931f0db8953de1.zip
op-kernel-dev-d0559a2f294c9b50d7795a8362931f0db8953de1.tar.gz
USB: serial: ftdi_sio: only allow valid event_char values
The "event_char" device attribute value, when written, is interpreted as an enable bit in bit 8, and an "event character" in bits 7 to 0. Return an error -EINVAL for out-of-range values. Use kstrtouint() to parse the integer instead of the obsolete simple_strtoul(). Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Johan Hovold <johan@kernel.org>
Diffstat (limited to 'drivers/usb/serial/ftdi_sio.c')
-rw-r--r--drivers/usb/serial/ftdi_sio.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index b774f9d..4032a67 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -1738,9 +1738,12 @@ static ssize_t store_event_char(struct device *dev,
struct usb_serial_port *port = to_usb_serial_port(dev);
struct ftdi_private *priv = usb_get_serial_port_data(port);
struct usb_device *udev = port->serial->dev;
- int v = simple_strtoul(valbuf, NULL, 10);
+ unsigned int v;
int rv;
+ if (kstrtouint(valbuf, 10, &v) || v >= 0x200)
+ return -EINVAL;
+
dev_dbg(&port->dev, "%s: setting event char = %i\n", __func__, v);
rv = usb_control_msg(udev,
OpenPOWER on IntegriCloud