aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2017-07-17 04:34:23 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-07-17 07:19:19 -0400
commit4ab3c51e0540ba8464fe34d84cc35821bb77ae92 (patch)
tree8b0b3a1c891e7496f470cdfcdb53acc46c051d8f
parent2b01bfaeb41e1563322448d9b392ac924cbf22ef (diff)
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: 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>
-rw-r--r--drivers/tty/serial/sh-sci.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index da5ddfc14778..e08b16b070c0 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -1085,10 +1085,12 @@ static ssize_t rx_trigger_store(struct device *dev,
1085{ 1085{
1086 struct uart_port *port = dev_get_drvdata(dev); 1086 struct uart_port *port = dev_get_drvdata(dev);
1087 struct sci_port *sci = to_sci_port(port); 1087 struct sci_port *sci = to_sci_port(port);
1088 int ret;
1088 long r; 1089 long r;
1089 1090
1090 if (kstrtol(buf, 0, &r) == -EINVAL) 1091 ret = kstrtol(buf, 0, &r);
1091 return -EINVAL; 1092 if (ret)
1093 return ret;
1092 1094
1093 sci->rx_trigger = scif_set_rtrg(port, r); 1095 sci->rx_trigger = scif_set_rtrg(port, r);
1094 if (port->type == PORT_SCIFA || port->type == PORT_SCIFB) 1096 if (port->type == PORT_SCIFA || port->type == PORT_SCIFB)
@@ -1116,10 +1118,12 @@ static ssize_t rx_fifo_timeout_store(struct device *dev,
1116{ 1118{
1117 struct uart_port *port = dev_get_drvdata(dev); 1119 struct uart_port *port = dev_get_drvdata(dev);
1118 struct sci_port *sci = to_sci_port(port); 1120 struct sci_port *sci = to_sci_port(port);
1121 int ret;
1119 long r; 1122 long r;
1120 1123
1121 if (kstrtol(buf, 0, &r) == -EINVAL) 1124 ret = kstrtol(buf, 0, &r);
1122 return -EINVAL; 1125 if (ret)
1126 return ret;
1123 sci->rx_fifo_timeout = r; 1127 sci->rx_fifo_timeout = r;
1124 scif_set_rtrg(port, 1); 1128 scif_set_rtrg(port, 1);
1125 if (r > 0) 1129 if (r > 0)