Commit 9edebf11 authored by Ursula Braun's avatar Ursula Braun Committed by David S. Miller

s390/netiucv: improve checking of sysfs attribute buffer

High values are always wrong for netiucv's sysfs attribute "buffer".
But the current code does not detect values between 2**31 and 2**32
as invalid. Choosing type "unsigned int" for variable "bs1" and making
use of "kstrtouint()" improves the syntax checking for "buffer".
Signed-off-by: default avatarUrsula Braun <ubraun@linux.vnet.ibm.com>
Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent baac7898
...@@ -1563,21 +1563,21 @@ static ssize_t buffer_write (struct device *dev, struct device_attribute *attr, ...@@ -1563,21 +1563,21 @@ static ssize_t buffer_write (struct device *dev, struct device_attribute *attr,
{ {
struct netiucv_priv *priv = dev_get_drvdata(dev); struct netiucv_priv *priv = dev_get_drvdata(dev);
struct net_device *ndev = priv->conn->netdev; struct net_device *ndev = priv->conn->netdev;
char *e; unsigned int bs1;
int bs1; int rc;
IUCV_DBF_TEXT(trace, 3, __func__); IUCV_DBF_TEXT(trace, 3, __func__);
if (count >= 39) if (count >= 39)
return -EINVAL; return -EINVAL;
bs1 = simple_strtoul(buf, &e, 0); rc = kstrtouint(buf, 0, &bs1);
if (e && (!isspace(*e))) { if (rc == -EINVAL) {
IUCV_DBF_TEXT_(setup, 2, "buffer_write: invalid char %02x\n", IUCV_DBF_TEXT_(setup, 2, "buffer_write: invalid char %s\n",
*e); buf);
return -EINVAL; return -EINVAL;
} }
if (bs1 > NETIUCV_BUFSIZE_MAX) { if ((rc == -ERANGE) || (bs1 > NETIUCV_BUFSIZE_MAX)) {
IUCV_DBF_TEXT_(setup, 2, IUCV_DBF_TEXT_(setup, 2,
"buffer_write: buffer size %d too large\n", "buffer_write: buffer size %d too large\n",
bs1); bs1);
......
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