diff mbox

PM QoS: Allow parsing of ASCII values

Message ID 20110222043336.GB23306@gvim.org (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

mark gross Feb. 22, 2011, 4:33 a.m. UTC
None
diff mbox

Patch

diff --git a/kernel/pm_qos_params.c b/kernel/pm_qos_params.c
index aeaa7f8..6cbce91 100644
--- a/kernel/pm_qos_params.c
+++ b/kernel/pm_qos_params.c
@@ -381,19 +381,18 @@  static ssize_t pm_qos_power_write(struct file *filp, const char __user *buf,
 {
 	s32 value;
 	int x;
-	char ascii_value[11];
+	char ascii_value[12];
 	struct pm_qos_request_list *pm_qos_req;
 
 	if (count == sizeof(s32)) {
 		if (copy_from_user(&value, buf, sizeof(s32)))
 			return -EFAULT;
-	} else if (count == 11) { /* len('0x12345678/0') */
-		if (copy_from_user(ascii_value, buf, 11))
+	} else if (count == 10 || count == 12) { /* '0x12345678' or
+						    '0x12345678/n/0'*/
+		memset(ascii_value, 0, sizeof(ascii_value));
+		if (copy_from_user(ascii_value, buf, count))
 			return -EFAULT;
-		if (strlen(ascii_value) != 10)
-			return -EINVAL;
-		x = sscanf(ascii_value, "%x", &value);
-		if (x != 1)
+		if (strict_strtoul(ascii_value,16,value) != 0)
 			return -EINVAL;
 		pr_debug("%s, %d, 0x%x\n", ascii_value, x, value);
 	} else