Commit fe29f54c authored by Andy Shevchenko's avatar Andy Shevchenko Committed by John W. Linville

ipw2x00: move to kstrto* functions

There is better to use kstrto* instead of simple_strtoul. In this case it
applies a bit stricter rules for input as well.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent af132051
...@@ -4167,17 +4167,11 @@ static ssize_t show_debug_level(struct device_driver *d, char *buf) ...@@ -4167,17 +4167,11 @@ static ssize_t show_debug_level(struct device_driver *d, char *buf)
static ssize_t store_debug_level(struct device_driver *d, static ssize_t store_debug_level(struct device_driver *d,
const char *buf, size_t count) const char *buf, size_t count)
{ {
char *p = (char *)buf;
u32 val; u32 val;
int ret;
if (p[1] == 'x' || p[1] == 'X' || p[0] == 'x' || p[0] == 'X') { ret = kstrtou32(buf, 0, &val);
p++; if (ret)
if (p[0] == 'x' || p[0] == 'X')
p++;
val = simple_strtoul(p, &p, 16);
} else
val = simple_strtoul(p, &p, 10);
if (p == buf)
IPW_DEBUG_INFO(": %s is not in hex or decimal form.\n", buf); IPW_DEBUG_INFO(": %s is not in hex or decimal form.\n", buf);
else else
ipw2100_debug_level = val; ipw2100_debug_level = val;
...@@ -4238,27 +4232,15 @@ static ssize_t store_scan_age(struct device *d, struct device_attribute *attr, ...@@ -4238,27 +4232,15 @@ static ssize_t store_scan_age(struct device *d, struct device_attribute *attr,
{ {
struct ipw2100_priv *priv = dev_get_drvdata(d); struct ipw2100_priv *priv = dev_get_drvdata(d);
struct net_device *dev = priv->net_dev; struct net_device *dev = priv->net_dev;
char buffer[] = "00000000";
unsigned long len =
(sizeof(buffer) - 1) > count ? count : sizeof(buffer) - 1;
unsigned long val; unsigned long val;
char *p = buffer; int ret;
(void)dev; /* kill unused-var warning for debug-only code */ (void)dev; /* kill unused-var warning for debug-only code */
IPW_DEBUG_INFO("enter\n"); IPW_DEBUG_INFO("enter\n");
strncpy(buffer, buf, len); ret = kstrtoul(buf, 0, &val);
buffer[len] = 0; if (ret) {
if (p[1] == 'x' || p[1] == 'X' || p[0] == 'x' || p[0] == 'X') {
p++;
if (p[0] == 'x' || p[0] == 'X')
p++;
val = simple_strtoul(p, &p, 16);
} else
val = simple_strtoul(p, &p, 10);
if (p == buffer) {
IPW_DEBUG_INFO("%s: user supplied invalid value.\n", dev->name); IPW_DEBUG_INFO("%s: user supplied invalid value.\n", dev->name);
} else { } else {
priv->ieee->scan_age = val; priv->ieee->scan_age = val;
...@@ -4266,7 +4248,7 @@ static ssize_t store_scan_age(struct device *d, struct device_attribute *attr, ...@@ -4266,7 +4248,7 @@ static ssize_t store_scan_age(struct device *d, struct device_attribute *attr,
} }
IPW_DEBUG_INFO("exit\n"); IPW_DEBUG_INFO("exit\n");
return len; return strnlen(buf, count);
} }
static DEVICE_ATTR(scan_age, S_IWUSR | S_IRUGO, show_scan_age, store_scan_age); static DEVICE_ATTR(scan_age, S_IWUSR | S_IRUGO, show_scan_age, store_scan_age);
......
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