lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1296915654-7458-5-git-send-email-adobriyan@gmail.com>
Date:	Sat,  5 Feb 2011 16:20:08 +0200
From:	Alexey Dobriyan <adobriyan@...il.com>
To:	akpm@...ux-foundation.org
Cc:	linux-kernel@...r.kernel.org, adobriyan@...il.com
Subject: [PATCH 05/52] kstrtox: convert block/


Signed-off-by: Alexey Dobriyan <adobriyan@...il.com>
---
 block/blk-cgroup.c |   47 ++++++++++++++++++++++++-----------------------
 1 files changed, 24 insertions(+), 23 deletions(-)

diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 455768a..d94110e 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -656,10 +656,9 @@ static int blkio_policy_parse_and_set(char *buf,
 {
 	char *s[4], *p, *major_s = NULL, *minor_s = NULL;
 	int ret;
-	unsigned long major, minor, temp;
+	unsigned int major, minor;
 	int i = 0;
 	dev_t dev;
-	u64 bps, iops;
 
 	memset(s, 0, sizeof(s));
 
@@ -687,15 +686,15 @@ static int blkio_policy_parse_and_set(char *buf,
 	if (!minor_s)
 		return -EINVAL;
 
-	ret = strict_strtoul(major_s, 10, &major);
-	if (ret)
-		return -EINVAL;
-
-	ret = strict_strtoul(minor_s, 10, &minor);
+	ret = kstrtouint(major_s, 10, &major);
+	if (ret < 0)
+		return ret;
+	ret = kstrtouint(minor_s, 10, &minor);
 	if (ret)
-		return -EINVAL;
-
+		return ret;
 	dev = MKDEV(major, minor);
+	if (MAJOR(dev) != major || MINOR(dev) != minor)
+		return -EINVAL;
 
 	ret = blkio_check_dev_num(dev);
 	if (ret)
@@ -707,40 +706,42 @@ static int blkio_policy_parse_and_set(char *buf,
 		return -EINVAL;
 
 	switch (plid) {
+		unsigned int weigth;
+
 	case BLKIO_POLICY_PROP:
-		ret = strict_strtoul(s[1], 10, &temp);
-		if (ret || (temp < BLKIO_WEIGHT_MIN && temp > 0) ||
-			temp > BLKIO_WEIGHT_MAX)
+		ret = kstrtouint(s[1], 10, &weigth);
+		if (ret < 0)
+			return ret;
+		if (weigth < BLKIO_WEIGHT_MIN || weigth > BLKIO_WEIGHT_MAX)
 			return -EINVAL;
 
 		newpn->plid = plid;
 		newpn->fileid = fileid;
-		newpn->val.weight = temp;
+		newpn->val.weight = weigth;
 		break;
 	case BLKIO_POLICY_THROTL:
 		switch(fileid) {
+			unsigned int iops;
+
 		case BLKIO_THROTL_read_bps_device:
 		case BLKIO_THROTL_write_bps_device:
-			ret = strict_strtoull(s[1], 10, &bps);
-			if (ret)
-				return -EINVAL;
-
 			newpn->plid = plid;
 			newpn->fileid = fileid;
-			newpn->val.bps = bps;
+			ret = kstrtou64(s[1], 10, &newpn->val.bps);
+			if (ret < 0)
+				return ret;
 			break;
 		case BLKIO_THROTL_read_iops_device:
 		case BLKIO_THROTL_write_iops_device:
-			ret = strict_strtoull(s[1], 10, &iops);
-			if (ret)
-				return -EINVAL;
-
+			ret = kstrtouint(s[1], 10, &iops);
+			if (ret < 0)
+				return ret;
 			if (iops > THROTL_IOPS_MAX)
 				return -EINVAL;
 
 			newpn->plid = plid;
 			newpn->fileid = fileid;
-			newpn->val.iops = (unsigned int)iops;
+			newpn->val.iops = iops;
 			break;
 		}
 		break;
-- 
1.7.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ