From patchwork Sun May 5 21:13:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Herrmann X-Patchwork-Id: 2521581 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 07F7E3FD4E for ; Sun, 5 May 2013 21:14:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752333Ab3EEVOZ (ORCPT ); Sun, 5 May 2013 17:14:25 -0400 Received: from mail-bk0-f49.google.com ([209.85.214.49]:35007 "EHLO mail-bk0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752288Ab3EEVOZ (ORCPT ); Sun, 5 May 2013 17:14:25 -0400 Received: by mail-bk0-f49.google.com with SMTP id e19so1352757bku.36 for ; Sun, 05 May 2013 14:14:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=3Tmv3Pd7/5wDxakdbnx5A6kQX0WwhhraUzkH7hc77ys=; b=v7wSjPWp2QpY3aKRnlc3jW5fvgmiRRl0h8J0s3EbPwIuULj12lultAqoCD7jPAFISJ R3FAKZAJeszRgp+ng6ckFOFMsd+NC5gQBAK1JR3MYZxARFy0YzO48A1o4bXEh6PLPpZ+ 5D113TWNPj5eEwExuDiHZdSbQI04YEsRPyx/51S8RFZlCxviUpD02nabyhVKs1hUCtAX eviBt1UhtYZJG8W2hMC9VWW7YEZazi1PZ8PPyUbANM1OGoA6fphU1w3fRJGppdOMEBFm kKbN2ChLh4Ru8ICmzkc9XOtjzOSOTqrYCW9I+T3pPoE+DPT3p3jKQAyjiXDtwU0mS5pc P/Ig== X-Received: by 10.204.108.3 with SMTP id d3mr7421014bkp.130.1367788463857; Sun, 05 May 2013 14:14:23 -0700 (PDT) Received: from localhost.localdomain (stgt-5f71a35b.pool.mediaWays.net. [95.113.163.91]) by mx.google.com with ESMTPSA id cv9sm4667233bkb.5.2013.05.05.14.14.22 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 05 May 2013 14:14:23 -0700 (PDT) From: David Herrmann To: linux-input@vger.kernel.org Cc: Jiri Kosina , David Herrmann Subject: [PATCH 25/26] HID: wiimote: fix DRM debug-attr to correctly parse input Date: Sun, 5 May 2013 23:13:09 +0200 Message-Id: <1367788390-29835-26-git-send-email-dh.herrmann@gmail.com> X-Mailer: git-send-email 1.8.2.2 In-Reply-To: <1367788390-29835-1-git-send-email-dh.herrmann@gmail.com> References: <1367788390-29835-1-git-send-email-dh.herrmann@gmail.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org We need to correctly zero-terminate the input to parse it. Otherwise, we always end up interpreting it as numbers. Furthermore, we actually want hexadecimal numbers instead of decimal. As it is a debugfs interface, we can change the API at any time. Signed-off-by: David Herrmann --- drivers/hid/hid-wiimote-debug.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c index 6e76a2c..c13fb5b 100644 --- a/drivers/hid/hid-wiimote-debug.c +++ b/drivers/hid/hid-wiimote-debug.c @@ -141,7 +141,7 @@ static ssize_t wiidebug_drm_write(struct file *f, const char __user *u, if (copy_from_user(buf, u, len)) return -EFAULT; - buf[15] = 0; + buf[len] = 0; for (i = 0; i < WIIPROTO_REQ_MAX; ++i) { if (!wiidebug_drmmap[i]) @@ -151,7 +151,7 @@ static ssize_t wiidebug_drm_write(struct file *f, const char __user *u, } if (i == WIIPROTO_REQ_MAX) - i = simple_strtoul(buf, NULL, 10); + i = simple_strtoul(buf, NULL, 16); spin_lock_irqsave(&dbg->wdata->state.lock, flags); dbg->wdata->state.flags &= ~WIIPROTO_FLAG_DRM_LOCKED;