From patchwork Sun May 26 20:55:03 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Herrmann X-Patchwork-Id: 2616861 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 75FB83FD2B for ; Sun, 26 May 2013 20:56:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755119Ab3EZU4E (ORCPT ); Sun, 26 May 2013 16:56:04 -0400 Received: from mail-bk0-f48.google.com ([209.85.214.48]:61803 "EHLO mail-bk0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755145Ab3EZU4D (ORCPT ); Sun, 26 May 2013 16:56:03 -0400 Received: by mail-bk0-f48.google.com with SMTP id jf20so1840722bkc.7 for ; Sun, 26 May 2013 13:56:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=7fSe/tIY44t/6SkOzjweYO3+qK7UhlTWfT6cyzZWic8=; b=HErmiyv79spTJvhcJLnjqSh6fiomqg1mQ0bWrynCj15j9kPcR/FEzoiIdrYlQsY9wY XCN8tJF9Sw+rTQJgm2NBiCxbjl7/ecwFvcuK7twrapXfJmUS2kTd3Aialqu6KRNgmd18 p13fh7vUKrOcldQISlfNdrlmnoj3sfVhPcUO88zG/UU+jUtv2ZRA1LFSliEVR78Zmyxb s2w2KtdwD/26JYUVERtpn7PAjFWKq4DB4ZkTh2BIJvG/qBM8GHD+rA5MQxvk7oo1ECIg 8T8sw0yPg5i0c4t6zyBjLWACDsV5gcMG1O8DUL9FgKexwfd30YxUuG7Spcvx4N27WFa/ Aq7A== X-Received: by 10.205.24.11 with SMTP id rc11mr2156917bkb.155.1369601762245; Sun, 26 May 2013 13:56:02 -0700 (PDT) Received: from localhost.localdomain (stgt-5f71b863.pool.mediaWays.net. [95.113.184.99]) by mx.google.com with ESMTPSA id og1sm3531965bkb.16.2013.05.26.13.56.00 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 26 May 2013 13:56:01 -0700 (PDT) From: David Herrmann To: linux-input@vger.kernel.org Cc: Jiri Kosina , David Herrmann Subject: [PATCH 28/26] HID: wiimote: discard invalid EXT data reports Date: Sun, 26 May 2013 22:55:03 +0200 Message-Id: <1369601704-2311-2-git-send-email-dh.herrmann@gmail.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1369601704-2311-1-git-send-email-dh.herrmann@gmail.com> References: <1367788390-29835-1-git-send-email-dh.herrmann@gmail.com> <1369601704-2311-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 If an extension device isn't initialized properly, or during hardware initialization, a device might send extension data which is all 0xff. This is ambigious because this is also a valid normal data report. But it is impossible, under normal conditions, to trigger valid reports with all 0xff. Hence, we can safely ignore them. Signed-off-by: David Herrmann --- drivers/hid/hid-wiimote-core.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/hid/hid-wiimote-core.c b/drivers/hid/hid-wiimote-core.c index f54595c..40fdc62 100644 --- a/drivers/hid/hid-wiimote-core.c +++ b/drivers/hid/hid-wiimote-core.c @@ -1335,11 +1335,19 @@ static bool valid_ext_handler(const struct wiimod_ops *ops, size_t len) static void handler_ext(struct wiimote_data *wdata, const __u8 *payload, size_t len) { + static const __u8 invalid[21] = { 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, + 0xff }; const __u8 *iter, *mods; const struct wiimod_ops *ops; bool is_mp; - if (len < 6) + if (len > 21) + len = 21; + if (len < 6 || !memcmp(payload, invalid, len)) return; /* if MP is active, track MP slot hotplugging */