aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390/cio/device.c
diff options
context:
space:
mode:
authorCornelia Huck <cornelia.huck@de.ibm.com>2008-04-30 07:38:33 -0400
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2008-04-30 07:38:43 -0400
commit2f972202315cf71fd60e890ebbed7d5bcf620ba4 (patch)
tree80e43d5bacb7b85417168bc257369d3642cc196c /drivers/s390/cio/device.c
parent0ff5ce7f30b45cc2014cec465c0e96c16877116e (diff)
[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.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c
index e0c7adb8958e..abfd601d237a 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,
512 const char *buf, size_t count) 512 const char *buf, size_t count)
513{ 513{
514 struct ccw_device *cdev = to_ccwdev(dev); 514 struct ccw_device *cdev = to_ccwdev(dev);
515 int i, force; 515 int force, ret;
516 char *tmp; 516 unsigned long i;
517 517
518 if (atomic_cmpxchg(&cdev->private->onoff, 0, 1) != 0) 518 if (atomic_cmpxchg(&cdev->private->onoff, 0, 1) != 0)
519 return -EAGAIN; 519 return -EAGAIN;
@@ -525,25 +525,30 @@ static ssize_t online_store (struct device *dev, struct device_attribute *attr,
525 if (!strncmp(buf, "force\n", count)) { 525 if (!strncmp(buf, "force\n", count)) {
526 force = 1; 526 force = 1;
527 i = 1; 527 i = 1;
528 ret = 0;
528 } else { 529 } else {
529 force = 0; 530 force = 0;
530 i = simple_strtoul(buf, &tmp, 16); 531 ret = strict_strtoul(buf, 16, &i);
531 } 532 }
532 533 if (ret)
534 goto out;
533 switch (i) { 535 switch (i) {
534 case 0: 536 case 0:
535 online_store_handle_offline(cdev); 537 online_store_handle_offline(cdev);
538 ret = count;
536 break; 539 break;
537 case 1: 540 case 1:
538 online_store_handle_online(cdev, force); 541 online_store_handle_online(cdev, force);
542 ret = count;
539 break; 543 break;
540 default: 544 default:
541 count = -EINVAL; 545 ret = -EINVAL;
542 } 546 }
547out:
543 if (cdev->drv) 548 if (cdev->drv)
544 module_put(cdev->drv->owner); 549 module_put(cdev->drv->owner);
545 atomic_set(&cdev->private->onoff, 0); 550 atomic_set(&cdev->private->onoff, 0);
546 return count; 551 return ret;
547} 552}
548 553
549static ssize_t 554static ssize_t