aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorHorst Hummel <horst.hummel@de.ibm.com>2006-12-04 09:39:50 -0500
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2006-12-04 09:39:50 -0500
commit01376f4495840f3daf6d73679242b5964fc9603b (patch)
tree51ef99991b42d6c623e5f1be980ff04026cc3ebb /drivers
parent26916264c17b5af8a3eaaf83b128f85cf1107cff (diff)
[S390] handle incorrect values when writing to dasd sysfs attributes.
When writing to dasd attributes (e.g. readonly), all values besides '1' are handled like '0'. Other sysfs-attributes like 'online' are checking for '1' and for '0' and do not accept other values. Therefore enhanced checking and error handling in dasd_devmap attribute store functions. Signed-off-by: Horst Hummel <horst.hummel@de.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/s390/block/dasd_devmap.c43
1 files changed, 29 insertions, 14 deletions
diff --git a/drivers/s390/block/dasd_devmap.c b/drivers/s390/block/dasd_devmap.c
index 91cf971f0652..b5e70c523921 100644
--- a/drivers/s390/block/dasd_devmap.c
+++ b/drivers/s390/block/dasd_devmap.c
@@ -684,21 +684,26 @@ dasd_ro_store(struct device *dev, struct device_attribute *attr,
684 const char *buf, size_t count) 684 const char *buf, size_t count)
685{ 685{
686 struct dasd_devmap *devmap; 686 struct dasd_devmap *devmap;
687 int ro_flag; 687 int val;
688 char *endp;
688 689
689 devmap = dasd_devmap_from_cdev(to_ccwdev(dev)); 690 devmap = dasd_devmap_from_cdev(to_ccwdev(dev));
690 if (IS_ERR(devmap)) 691 if (IS_ERR(devmap))
691 return PTR_ERR(devmap); 692 return PTR_ERR(devmap);
692 ro_flag = buf[0] == '1'; 693
694 val = simple_strtoul(buf, &endp, 0);
695 if (((endp + 1) < (buf + count)) || (val > 1))
696 return -EINVAL;
697
693 spin_lock(&dasd_devmap_lock); 698 spin_lock(&dasd_devmap_lock);
694 if (ro_flag) 699 if (val)
695 devmap->features |= DASD_FEATURE_READONLY; 700 devmap->features |= DASD_FEATURE_READONLY;
696 else 701 else
697 devmap->features &= ~DASD_FEATURE_READONLY; 702 devmap->features &= ~DASD_FEATURE_READONLY;
698 if (devmap->device) 703 if (devmap->device)
699 devmap->device->features = devmap->features; 704 devmap->device->features = devmap->features;
700 if (devmap->device && devmap->device->gdp) 705 if (devmap->device && devmap->device->gdp)
701 set_disk_ro(devmap->device->gdp, ro_flag); 706 set_disk_ro(devmap->device->gdp, val);
702 spin_unlock(&dasd_devmap_lock); 707 spin_unlock(&dasd_devmap_lock);
703 return count; 708 return count;
704} 709}
@@ -729,17 +734,22 @@ dasd_use_diag_store(struct device *dev, struct device_attribute *attr,
729{ 734{
730 struct dasd_devmap *devmap; 735 struct dasd_devmap *devmap;
731 ssize_t rc; 736 ssize_t rc;
732 int use_diag; 737 int val;
738 char *endp;
733 739
734 devmap = dasd_devmap_from_cdev(to_ccwdev(dev)); 740 devmap = dasd_devmap_from_cdev(to_ccwdev(dev));
735 if (IS_ERR(devmap)) 741 if (IS_ERR(devmap))
736 return PTR_ERR(devmap); 742 return PTR_ERR(devmap);
737 use_diag = buf[0] == '1'; 743
744 val = simple_strtoul(buf, &endp, 0);
745 if (((endp + 1) < (buf + count)) || (val > 1))
746 return -EINVAL;
747
738 spin_lock(&dasd_devmap_lock); 748 spin_lock(&dasd_devmap_lock);
739 /* Changing diag discipline flag is only allowed in offline state. */ 749 /* Changing diag discipline flag is only allowed in offline state. */
740 rc = count; 750 rc = count;
741 if (!devmap->device) { 751 if (!devmap->device) {
742 if (use_diag) 752 if (val)
743 devmap->features |= DASD_FEATURE_USEDIAG; 753 devmap->features |= DASD_FEATURE_USEDIAG;
744 else 754 else
745 devmap->features &= ~DASD_FEATURE_USEDIAG; 755 devmap->features &= ~DASD_FEATURE_USEDIAG;
@@ -854,20 +864,25 @@ dasd_eer_store(struct device *dev, struct device_attribute *attr,
854 const char *buf, size_t count) 864 const char *buf, size_t count)
855{ 865{
856 struct dasd_devmap *devmap; 866 struct dasd_devmap *devmap;
857 int rc; 867 int val, rc;
868 char *endp;
858 869
859 devmap = dasd_devmap_from_cdev(to_ccwdev(dev)); 870 devmap = dasd_devmap_from_cdev(to_ccwdev(dev));
860 if (IS_ERR(devmap)) 871 if (IS_ERR(devmap))
861 return PTR_ERR(devmap); 872 return PTR_ERR(devmap);
862 if (!devmap->device) 873 if (!devmap->device)
863 return count; 874 return -ENODEV;
864 if (buf[0] == '1') { 875
876 val = simple_strtoul(buf, &endp, 0);
877 if (((endp + 1) < (buf + count)) || (val > 1))
878 return -EINVAL;
879
880 rc = count;
881 if (val)
865 rc = dasd_eer_enable(devmap->device); 882 rc = dasd_eer_enable(devmap->device);
866 if (rc) 883 else
867 return rc;
868 } else
869 dasd_eer_disable(devmap->device); 884 dasd_eer_disable(devmap->device);
870 return count; 885 return rc;
871} 886}
872 887
873static DEVICE_ATTR(eer_enabled, 0644, dasd_eer_show, dasd_eer_store); 888static DEVICE_ATTR(eer_enabled, 0644, dasd_eer_show, dasd_eer_store);