From patchwork Sun Mar 6 14:07:14 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: mark gross X-Patchwork-Id: 613481 Received: from smtp1.linux-foundation.org (smtp1.linux-foundation.org [140.211.169.13]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p26E9kaU026828 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Sun, 6 Mar 2011 14:10:08 GMT Received: from daredevil.linux-foundation.org (localhost [127.0.0.1]) by smtp1.linux-foundation.org (8.14.2/8.13.5/Debian-3ubuntu1.1) with ESMTP id p26E7NTR025352; Sun, 6 Mar 2011 06:07:24 -0800 Received: from mail-iy0-f175.google.com (mail-iy0-f175.google.com [209.85.210.175]) by smtp1.linux-foundation.org (8.14.2/8.13.5/Debian-3ubuntu1.1) with ESMTP id p26E7JSF025343 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=FAIL) for ; Sun, 6 Mar 2011 06:07:21 -0800 Received: by iyb26 with SMTP id 26so3448533iyb.6 for ; Sun, 06 Mar 2011 06:07:19 -0800 (PST) Received: by 10.42.140.65 with SMTP id j1mr3280088icu.454.1299420439203; Sun, 06 Mar 2011 06:07:19 -0800 (PST) Received: from localhost (c-24-22-115-171.hsd1.or.comcast.net [24.22.115.171]) by mx.google.com with ESMTPS id gy41sm1759242ibb.11.2011.03.06.06.07.15 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 06 Mar 2011 06:07:17 -0800 (PST) Date: Sun, 6 Mar 2011 06:07:14 -0800 From: mark gross To: Alan Stern Message-ID: <20110306140714.GA2438@gvim.org> References: <20110224161732.GA6512@gvim.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) Received-SPF: pass (localhost is always allowed.) X-Spam-Status: No, hits=-6.295 required=5 tests=AWL, BAYES_00, OSDL_HEADER_SPF_PASS, OSDL_HEADER_SUBJECT_BRACKETED, PATCH_SUBJECT_OSDL X-Spam-Checker-Version: SpamAssassin 3.2.4-osdl_revision__1.47__ X-MIMEDefang-Filter: lf$Revision: 1.188 $ X-Scanned-By: MIMEDefang 2.63 on 140.211.169.21 Cc: linux-pm@lists.linux-foundation.org, Dan Carpenter , mark gross Subject: Re: [linux-pm] [PATCH] PM QoS: Allow parsing of ASCII values X-BeenThere: linux-pm@lists.linux-foundation.org X-Mailman-Version: 2.1.9 Precedence: list Reply-To: markgross@thegnar.org List-Id: Linux power management List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-pm-bounces@lists.linux-foundation.org Errors-To: linux-pm-bounces@lists.linux-foundation.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Sun, 06 Mar 2011 14:10:08 +0000 (UTC) diff --git a/kernel/pm_qos_params.c b/kernel/pm_qos_params.c index aeaa7f8..b315446 100644 --- a/kernel/pm_qos_params.c +++ b/kernel/pm_qos_params.c @@ -40,6 +40,7 @@ #include #include #include +#include #include @@ -387,15 +388,15 @@ 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 == 10 || count == 11) { /* '0x12345678' or + '0x12345678/n'*/ + ascii_value[count] = 0; + if (copy_from_user(ascii_value, buf, count)) return -EFAULT; - if (strlen(ascii_value) != 10) + if ((x=strict_strtol(ascii_value, 16, &value)) != 0){ + pr_debug("%s, 0x%x, 0x%x\n",ascii_value, value, x); return -EINVAL; - x = sscanf(ascii_value, "%x", &value); - if (x != 1) - return -EINVAL; - pr_debug("%s, %d, 0x%x\n", ascii_value, x, value); + } } else return -EINVAL;