]> git.karo-electronics.de Git - linux-beck.git/commitdiff
chipidea: error on overflow for port_test_write
authorAlan <gnomes@lxorguk.ukuu.org.uk>
Mon, 15 Feb 2016 19:09:46 +0000 (19:09 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 21 Feb 2016 04:15:57 +0000 (20:15 -0800)
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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/chipidea/debug.c

index de5c5092d078aef1ca90c45e7136b575490673a6..6d23eede4d8cda5014b041f965f3e060d201be74 100644 (file)
@@ -100,6 +100,9 @@ static ssize_t ci_port_test_write(struct file *file, const char __user *ubuf,
        if (sscanf(buf, "%u", &mode) != 1)
                return -EINVAL;
 
+       if (mode > 255)
+               return -EBADRQC;
+
        pm_runtime_get_sync(ci->dev);
        spin_lock_irqsave(&ci->lock, flags);
        ret = hw_port_test_set(ci, mode);