Commit 4ab3c51e authored by Dan Carpenter's avatar Dan Carpenter Committed by Greg Kroah-Hartman

serial: sh-sci: Uninitialized variables in sysfs files

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: 5d23188a ("serial: sh-sci: make RX FIFO parameters tunable via sysfs")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 2b01bfae
...@@ -1085,10 +1085,12 @@ static ssize_t rx_trigger_store(struct device *dev, ...@@ -1085,10 +1085,12 @@ static ssize_t rx_trigger_store(struct device *dev,
{ {
struct uart_port *port = dev_get_drvdata(dev); struct uart_port *port = dev_get_drvdata(dev);
struct sci_port *sci = to_sci_port(port); struct sci_port *sci = to_sci_port(port);
int ret;
long r; long r;
if (kstrtol(buf, 0, &r) == -EINVAL) ret = kstrtol(buf, 0, &r);
return -EINVAL; if (ret)
return ret;
sci->rx_trigger = scif_set_rtrg(port, r); sci->rx_trigger = scif_set_rtrg(port, r);
if (port->type == PORT_SCIFA || port->type == PORT_SCIFB) if (port->type == PORT_SCIFA || port->type == PORT_SCIFB)
...@@ -1116,10 +1118,12 @@ static ssize_t rx_fifo_timeout_store(struct device *dev, ...@@ -1116,10 +1118,12 @@ static ssize_t rx_fifo_timeout_store(struct device *dev,
{ {
struct uart_port *port = dev_get_drvdata(dev); struct uart_port *port = dev_get_drvdata(dev);
struct sci_port *sci = to_sci_port(port); struct sci_port *sci = to_sci_port(port);
int ret;
long r; long r;
if (kstrtol(buf, 0, &r) == -EINVAL) ret = kstrtol(buf, 0, &r);
return -EINVAL; if (ret)
return ret;
sci->rx_fifo_timeout = r; sci->rx_fifo_timeout = r;
scif_set_rtrg(port, 1); scif_set_rtrg(port, 1);
if (r > 0) if (r > 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment