diff options
Diffstat (limited to 'block/blk-cgroup.c')
-rw-r--r-- | block/blk-cgroup.c | 37 |
1 files changed, 16 insertions, 21 deletions
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index bcaf16ee6ad1..b596e54ddd71 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c | |||
@@ -785,10 +785,10 @@ static int blkio_policy_parse_and_set(char *buf, | |||
785 | { | 785 | { |
786 | char *s[4], *p, *major_s = NULL, *minor_s = NULL; | 786 | char *s[4], *p, *major_s = NULL, *minor_s = NULL; |
787 | int ret; | 787 | int ret; |
788 | unsigned long major, minor, temp; | 788 | unsigned long major, minor; |
789 | int i = 0; | 789 | int i = 0; |
790 | dev_t dev; | 790 | dev_t dev; |
791 | u64 bps, iops; | 791 | u64 temp; |
792 | 792 | ||
793 | memset(s, 0, sizeof(s)); | 793 | memset(s, 0, sizeof(s)); |
794 | 794 | ||
@@ -826,20 +826,23 @@ static int blkio_policy_parse_and_set(char *buf, | |||
826 | 826 | ||
827 | dev = MKDEV(major, minor); | 827 | dev = MKDEV(major, minor); |
828 | 828 | ||
829 | ret = blkio_check_dev_num(dev); | 829 | ret = strict_strtoull(s[1], 10, &temp); |
830 | if (ret) | 830 | if (ret) |
831 | return ret; | 831 | return -EINVAL; |
832 | 832 | ||
833 | newpn->dev = dev; | 833 | /* For rule removal, do not check for device presence. */ |
834 | if (temp) { | ||
835 | ret = blkio_check_dev_num(dev); | ||
836 | if (ret) | ||
837 | return ret; | ||
838 | } | ||
834 | 839 | ||
835 | if (s[1] == NULL) | 840 | newpn->dev = dev; |
836 | return -EINVAL; | ||
837 | 841 | ||
838 | switch (plid) { | 842 | switch (plid) { |
839 | case BLKIO_POLICY_PROP: | 843 | case BLKIO_POLICY_PROP: |
840 | ret = strict_strtoul(s[1], 10, &temp); | 844 | if ((temp < BLKIO_WEIGHT_MIN && temp > 0) || |
841 | if (ret || (temp < BLKIO_WEIGHT_MIN && temp > 0) || | 845 | temp > BLKIO_WEIGHT_MAX) |
842 | temp > BLKIO_WEIGHT_MAX) | ||
843 | return -EINVAL; | 846 | return -EINVAL; |
844 | 847 | ||
845 | newpn->plid = plid; | 848 | newpn->plid = plid; |
@@ -850,26 +853,18 @@ static int blkio_policy_parse_and_set(char *buf, | |||
850 | switch(fileid) { | 853 | switch(fileid) { |
851 | case BLKIO_THROTL_read_bps_device: | 854 | case BLKIO_THROTL_read_bps_device: |
852 | case BLKIO_THROTL_write_bps_device: | 855 | case BLKIO_THROTL_write_bps_device: |
853 | ret = strict_strtoull(s[1], 10, &bps); | ||
854 | if (ret) | ||
855 | return -EINVAL; | ||
856 | |||
857 | newpn->plid = plid; | 856 | newpn->plid = plid; |
858 | newpn->fileid = fileid; | 857 | newpn->fileid = fileid; |
859 | newpn->val.bps = bps; | 858 | newpn->val.bps = temp; |
860 | break; | 859 | break; |
861 | case BLKIO_THROTL_read_iops_device: | 860 | case BLKIO_THROTL_read_iops_device: |
862 | case BLKIO_THROTL_write_iops_device: | 861 | case BLKIO_THROTL_write_iops_device: |
863 | ret = strict_strtoull(s[1], 10, &iops); | 862 | if (temp > THROTL_IOPS_MAX) |
864 | if (ret) | ||
865 | return -EINVAL; | ||
866 | |||
867 | if (iops > THROTL_IOPS_MAX) | ||
868 | return -EINVAL; | 863 | return -EINVAL; |
869 | 864 | ||
870 | newpn->plid = plid; | 865 | newpn->plid = plid; |
871 | newpn->fileid = fileid; | 866 | newpn->fileid = fileid; |
872 | newpn->val.iops = (unsigned int)iops; | 867 | newpn->val.iops = (unsigned int)temp; |
873 | break; | 868 | break; |
874 | } | 869 | } |
875 | break; | 870 | break; |