diff options
author | Alan <gnomes@lxorguk.ukuu.org.uk> | 2016-02-15 14:09:46 -0500 |
---|---|---|
committer | Peter Chen <peter.chen@nxp.com> | 2016-02-19 01:12:39 -0500 |
commit | a4de018d2b0364e40a626fa521ec21e31a10ac84 (patch) | |
tree | e8977ba2b54a4cf8a8f4a87ad479d74e270ae6aa | |
parent | 18558cae0272f8fd9647e69d3fec1565a7949865 (diff) |
usb: chipidea: error on overflow for port_test_write
The write value is 8bit, but currently writing a larger number
(eg a doubled digit) is not errored but instead gets cast and
sets off an action probably undesired.
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Peter Chen <peter.chen@nxp.com>
(Change the style of commit log to fix checkpatch.pl warning)
-rw-r--r-- | drivers/usb/chipidea/debug.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/usb/chipidea/debug.c b/drivers/usb/chipidea/debug.c index a4f7db2e18dd..df47110bad2d 100644 --- a/drivers/usb/chipidea/debug.c +++ b/drivers/usb/chipidea/debug.c | |||
@@ -100,6 +100,9 @@ static ssize_t ci_port_test_write(struct file *file, const char __user *ubuf, | |||
100 | if (sscanf(buf, "%u", &mode) != 1) | 100 | if (sscanf(buf, "%u", &mode) != 1) |
101 | return -EINVAL; | 101 | return -EINVAL; |
102 | 102 | ||
103 | if (mode > 255) | ||
104 | return -EBADRQC; | ||
105 | |||
103 | pm_runtime_get_sync(ci->dev); | 106 | pm_runtime_get_sync(ci->dev); |
104 | spin_lock_irqsave(&ci->lock, flags); | 107 | spin_lock_irqsave(&ci->lock, flags); |
105 | ret = hw_port_test_set(ci, mode); | 108 | ret = hw_port_test_set(ci, mode); |