public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] PM QoS: Allow parsing of ASCII values
@ 2011-02-18  1:54 Simon Horman
  2011-02-18  5:05 ` mark gross
  2011-02-22  4:33 ` mark gross
  0 siblings, 2 replies; 13+ messages in thread
From: Simon Horman @ 2011-02-18  1:54 UTC (permalink / raw)
  To: linux-pm; +Cc: Dan Carpenter, Mark Gross

In "PM QoS: Correct pr_debug() misuse and improve parameter checks"
the parsing of the ASCII hex value was tightened. Unfortunately
it was tightened to the point where no value is valid.

Root of the problem seems to lie in wheather the ASCII hex is followed
by a '\n' or not. My reading of the documentation is that the '\n' should
not be present. However the code previously only accepted that version.
The current code accepts neither. My fix is to accept both.

Cc: Mark Gross <markgross@thegnar.org>
Cc: Dan Carpenter <error27@gmail.com>
Cc: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Simon Horman <horms@verge.net.au>

---
This appears to have been introduced around 2.6.36-rc4.
And was an @stable patch. As such I believe this change
is stable material.
---
 kernel/pm_qos_params.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/kernel/pm_qos_params.c b/kernel/pm_qos_params.c
index aeaa7f8..98a34ea 100644
--- a/kernel/pm_qos_params.c
+++ b/kernel/pm_qos_params.c
@@ -387,10 +387,11 @@ static ssize_t pm_qos_power_write(struct file *filp, const char __user *buf,
 	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 == 11 || count == 10) { /* len('0x12345678\n') or
+						  * len('0x12345678') */
+		if (copy_from_user(ascii_value, buf, count))
 			return -EFAULT;
-		if (strlen(ascii_value) != 10)
+		if (strlen(ascii_value) != count)
 			return -EINVAL;
 		x = sscanf(ascii_value, "%x", &value);
 		if (x != 1)
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2011-03-30  7:11 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-18  1:54 [PATCH] PM QoS: Allow parsing of ASCII values Simon Horman
2011-02-18  5:05 ` mark gross
2011-02-18  6:39   ` Simon Horman
2011-02-18 15:17     ` Alan Stern
2011-02-22  4:33 ` mark gross
2011-02-23  6:56   ` mark gross
2011-02-23 15:20     ` Alan Stern
2011-02-24 16:17       ` mark gross
2011-02-24 17:00         ` Alan Stern
2011-03-06 14:07           ` mark gross
2011-03-29 20:01             ` Rafael J. Wysocki
2011-03-30  3:59               ` mark gross
2011-03-30  7:11                 ` Simon Horman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox