diff options
author | Cornelia Huck <cornelia.huck@de.ibm.com> | 2008-04-30 13:38:33 +0200 |
---|---|---|
committer | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2008-04-30 13:38:43 +0200 |
commit | 2f972202315cf71fd60e890ebbed7d5bcf620ba4 (patch) | |
tree | 80e43d5bacb7b85417168bc257369d3642cc196c /drivers/s390/cio/device.c | |
parent | 0ff5ce7f30b45cc2014cec465c0e96c16877116e (diff) | |
download | op-kernel-dev-2f972202315cf71fd60e890ebbed7d5bcf620ba4.zip op-kernel-dev-2f972202315cf71fd60e890ebbed7d5bcf620ba4.tar.gz |
[S390] cio: Use strict_strtoul() for attributes.
Make parsing of attribute writes handle incorrect input better.
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'drivers/s390/cio/device.c')
-rw-r--r-- | drivers/s390/cio/device.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c index e0c7adb..abfd601 100644 --- a/drivers/s390/cio/device.c +++ b/drivers/s390/cio/device.c @@ -512,8 +512,8 @@ static ssize_t online_store (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct ccw_device *cdev = to_ccwdev(dev); - int i, force; - char *tmp; + int force, ret; + unsigned long i; if (atomic_cmpxchg(&cdev->private->onoff, 0, 1) != 0) return -EAGAIN; @@ -525,25 +525,30 @@ static ssize_t online_store (struct device *dev, struct device_attribute *attr, if (!strncmp(buf, "force\n", count)) { force = 1; i = 1; + ret = 0; } else { force = 0; - i = simple_strtoul(buf, &tmp, 16); + ret = strict_strtoul(buf, 16, &i); } - + if (ret) + goto out; switch (i) { case 0: online_store_handle_offline(cdev); + ret = count; break; case 1: online_store_handle_online(cdev, force); + ret = count; break; default: - count = -EINVAL; + ret = -EINVAL; } +out: if (cdev->drv) module_put(cdev->drv->owner); atomic_set(&cdev->private->onoff, 0); - return count; + return ret; } static ssize_t |