]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
serial: sh-sci: Uninitialized variables in sysfs files
authorDan Carpenter <dan.carpenter@oracle.com>
Mon, 17 Jul 2017 08:34:23 +0000 (11:34 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 17 Jul 2017 11:19:19 +0000 (13:19 +0200)
The kstrtol() function returns -ERANGE as well as -EINVAL so these tests
are not enough.  It's not a super serious bug, but my static checker
correctly complains that the "r" variable might be used uninitialized.

Fixes: 5d23188a473d ("serial: sh-sci: make RX FIFO parameters tunable via sysfs")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/sh-sci.c

index da5ddfc14778869cdc8974fa618a923ba75c90ea..e08b16b070c0fb914916dd6c2f78fcf3546edfea 100644 (file)
@@ -1085,10 +1085,12 @@ static ssize_t rx_trigger_store(struct device *dev,
 {
        struct uart_port *port = dev_get_drvdata(dev);
        struct sci_port *sci = to_sci_port(port);
+       int ret;
        long r;
 
-       if (kstrtol(buf, 0, &r) == -EINVAL)
-               return -EINVAL;
+       ret = kstrtol(buf, 0, &r);
+       if (ret)
+               return ret;
 
        sci->rx_trigger = scif_set_rtrg(port, r);
        if (port->type == PORT_SCIFA || port->type == PORT_SCIFB)
@@ -1116,10 +1118,12 @@ static ssize_t rx_fifo_timeout_store(struct device *dev,
 {
        struct uart_port *port = dev_get_drvdata(dev);
        struct sci_port *sci = to_sci_port(port);
+       int ret;
        long r;
 
-       if (kstrtol(buf, 0, &r) == -EINVAL)
-               return -EINVAL;
+       ret = kstrtol(buf, 0, &r);
+       if (ret)
+               return ret;
        sci->rx_fifo_timeout = r;
        scif_set_rtrg(port, 1);
        if (r > 0)