From patchwork Tue Feb 22 04:33:36 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: mark gross X-Patchwork-Id: 579241 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 p1M4ZeY0001947 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Tue, 22 Feb 2011 04:36:03 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 p1M4Xk9Y006175; Mon, 21 Feb 2011 20:33:47 -0800 Received: from mail-yw0-f47.google.com (mail-yw0-f47.google.com [209.85.213.47]) by smtp1.linux-foundation.org (8.14.2/8.13.5/Debian-3ubuntu1.1) with ESMTP id p1M4XfpA006164 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=FAIL) for ; Mon, 21 Feb 2011 20:33:42 -0800 Received: by ywg8 with SMTP id 8so738611ywg.6 for ; Mon, 21 Feb 2011 20:33:41 -0800 (PST) Received: by 10.151.6.5 with SMTP id j5mr2754276ybi.308.1298349220912; Mon, 21 Feb 2011 20:33:40 -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 y21sm3796644yhc.18.2011.02.21.20.33.38 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 21 Feb 2011 20:33:39 -0800 (PST) Date: Mon, 21 Feb 2011 20:33:36 -0800 From: mark gross To: Simon Horman Message-ID: <20110222043336.GB23306@gvim.org> References: <1297994096-1839-1-git-send-email-horms@verge.net.au> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1297994096-1839-1-git-send-email-horms@verge.net.au> User-Agent: Mutt/1.5.20 (2009-06-14) Received-SPF: pass (localhost is always allowed.) X-Spam-Status: No, hits=-6.257 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]); Tue, 22 Feb 2011 04:36:06 +0000 (UTC) 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