From patchwork Tue Jun 7 20:36:14 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Peter_H=C3=BCwe?= X-Patchwork-Id: 99325 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3C29FB6F6C for ; Wed, 8 Jun 2011 06:36:56 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756642Ab1FGUg3 (ORCPT ); Tue, 7 Jun 2011 16:36:29 -0400 Received: from mailout-de.gmx.net ([213.165.64.22]:50680 "HELO mailout-de.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1756636Ab1FGUg2 (ORCPT ); Tue, 7 Jun 2011 16:36:28 -0400 Received: (qmail invoked by alias); 07 Jun 2011 20:36:24 -0000 Received: from dslb-088-064-077-152.pools.arcor-ip.net (EHLO localhost.localdomain) [88.64.77.152] by mail.gmx.net (mp030) with SMTP; 07 Jun 2011 22:36:24 +0200 X-Authenticated: #12255092 X-Provags-ID: V01U2FsdGVkX1/7Z40dR9z7L+TjDd111XqKET+dfpY+4Yd60pt0hS FbKbfgxpinv+Jt From: Peter Huewe To: Johannes Berg Cc: "John W. Linville" , "David S. Miller" , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Peter Huewe Subject: [PATCH] net/mac80211/debugfs: Convert to kstrou8_from_user Date: Tue, 7 Jun 2011 22:36:14 +0200 Message-Id: <1307478974-32727-1-git-send-email-peterhuewe@gmx.de> X-Mailer: git-send-email 1.7.3.4 X-Y-GMX-Trusted: 0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch replaces the code for getting an number from a userspace buffer by a simple call to kstrou8_from_user. This makes it easier to read and less error prone. Since the old buffer was only 10 bytes long and the value is masked by a nibble-mask anyway, we don't need to use kstrtoul but rather kstrtou8. Kernel Version: v3.0-rc2 Signed-off-by: Peter Huewe --- net/mac80211/debugfs.c | 14 +++----------- 1 files changed, 3 insertions(+), 11 deletions(-) diff --git a/net/mac80211/debugfs.c b/net/mac80211/debugfs.c index 186e02f..267ed45 100644 --- a/net/mac80211/debugfs.c +++ b/net/mac80211/debugfs.c @@ -195,20 +195,12 @@ static ssize_t uapsd_queues_write(struct file *file, size_t count, loff_t *ppos) { struct ieee80211_local *local = file->private_data; - unsigned long val; - char buf[10]; - size_t len; + u8 val; int ret; - len = min(count, sizeof(buf) - 1); - if (copy_from_user(buf, user_buf, len)) - return -EFAULT; - buf[len] = '\0'; - - ret = strict_strtoul(buf, 0, &val); - + ret = kstrtou8_from_user(user_buf, count, 0, &val); if (ret) - return -EINVAL; + return ret; if (val & ~IEEE80211_WMM_IE_STA_QOSINFO_AC_MASK) return -ERANGE;