From patchwork Fri Dec 9 06:04:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ping Cheng X-Patchwork-Id: 9467551 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9F059602F0 for ; Fri, 9 Dec 2016 06:05:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 89CCF2861A for ; Fri, 9 Dec 2016 06:05:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7C6142861F; Fri, 9 Dec 2016 06:05:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F311B2861A for ; Fri, 9 Dec 2016 06:05:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754075AbcLIGFX (ORCPT ); Fri, 9 Dec 2016 01:05:23 -0500 Received: from mail-pg0-f65.google.com ([74.125.83.65]:33180 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751570AbcLIGFW (ORCPT ); Fri, 9 Dec 2016 01:05:22 -0500 Received: by mail-pg0-f65.google.com with SMTP id 3so1203470pgd.0 for ; Thu, 08 Dec 2016 22:05:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=0TFoc06RvTErPvryiWBKsRlYK4Ck3nsnwJV5QcNcA/c=; b=sZ4LQQGjFyhHXDoo2//FQTYP/8cDrsXYZaZw6a41Wv8QljcXgdOo/WQND3s1vkCwQD GoiOmhC2mqiOPqHmTAVX+66W4Fh//xXkeabiHmwH7U8j9UvD4VgnfnXTdTBrvUfl7cuh yQfdvD0hfNjM0dZvg7ElLarhhg1xIk7XYoNzypdj73fx5PnfFoesIX7sJK8SOiRBCMmT L/0moj/VXWAevtX/5x0yjGh3VTkFQ/fCp83ocLI8ghoZPEikRGy99i16k+Y1VnJpXd4J GFM6bi2jJw938eZwr+Rp0i4nXcJpZfiHCGO43cwjtiiAwiPitT8jjYmuD823cfWgoDe4 eDAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=0TFoc06RvTErPvryiWBKsRlYK4Ck3nsnwJV5QcNcA/c=; b=m1ncfIgJX2ac1uLTJHMYugEajO4K17iq2VM/yO4G3N4Ir9+S1kAB9eBqrBppSkAwU0 7mUTWNJ0tBQCJxjNuyDAGwCcr6YaCl1up9lHO5PoN4QnEoDz0/d3GRw9sZC0qimVYuJC xHHjsWWIsHH9b0T+8HW/5hWH2quJR53BAME6Q/zEcdIUSKawQBB2zn1NkqWDt/WPmo6g imxhOXc9Gn7TB1apWwPN8Tb1NbHKl3Q0Q3upr/JLV131r9Tp9SbEN9lcBRAsMXmeOVdd wR8kPu+QpqFxjDFJK/99do/71WZI2LzvAJXKernpgOZEcHTisnrsXXTKle0/4EJ78yZE Jy2w== X-Gm-Message-State: AKaTC03y+1f30+k/lMCUhoka5TisIlpr7yhI9CqSXcSV5yh/BG+6cwstq6HD+EzQHjIHmQ== X-Received: by 10.99.47.7 with SMTP id v7mr142223595pgv.39.1481263522301; Thu, 08 Dec 2016 22:05:22 -0800 (PST) Received: from localhost.net (c-24-21-228-48.hsd1.wa.comcast.net. [24.21.228.48]) by smtp.gmail.com with ESMTPSA id q26sm54017705pfk.94.2016.12.08.22.05.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Dec 2016 22:05:21 -0800 (PST) From: Ping Cheng X-Google-Original-From: Ping Cheng To: linux-input@vger.kernel.org Cc: jikos@kernel.org, jason.gerecke@wacom.com, Ping Cheng , Ping Cheng Subject: [PATCH 2/4 v2] HID: wacom: generic: Send data only when the interface is defined Date: Thu, 8 Dec 2016 22:04:52 -0800 Message-Id: <1481263492-6729-1-git-send-email-pingc@wacom.com> X-Mailer: git-send-email 1.8.3.1 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Ping Cheng Sometime valid events may not be supported by the driver yet. Make sure we don't process them when the code is not ready. This fix prevents a kernel panic due to unsupported HID events. Signed-off-by: Ping Cheng Reviewed-By: Jason Gerecke --- drivers/hid/wacom_wac.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c index f1c49a4..29d2610 100644 --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c @@ -2109,11 +2109,11 @@ void wacom_wac_event(struct hid_device *hdev, struct hid_field *field, if (wacom->wacom_wac.features.type != HID_GENERIC) return; - if (WACOM_PAD_FIELD(field)) + if (WACOM_PAD_FIELD(field) && wacom->wacom_wac.pad_input) wacom_wac_pad_event(hdev, field, usage, value); - else if (WACOM_PEN_FIELD(field)) + else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input) wacom_wac_pen_event(hdev, field, usage, value); - else if (WACOM_FINGER_FIELD(field)) + else if (WACOM_FINGER_FIELD(field) && wacom->wacom_wac.touch_input) wacom_wac_finger_event(hdev, field, usage, value); } @@ -2145,20 +2145,20 @@ void wacom_wac_report(struct hid_device *hdev, struct hid_report *report) if (wacom_wac->features.type != HID_GENERIC) return; - if (WACOM_PAD_FIELD(field)) + if (WACOM_PAD_FIELD(field) && wacom->wacom_wac.pad_input) wacom_wac_pad_pre_report(hdev, report); - else if (WACOM_PEN_FIELD(field)) + else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input) wacom_wac_pen_pre_report(hdev, report); - else if (WACOM_FINGER_FIELD(field)) + else if (WACOM_FINGER_FIELD(field) && wacom->wacom_wac.touch_input) wacom_wac_finger_pre_report(hdev, report); wacom_report_events(hdev, report); - if (WACOM_PAD_FIELD(field)) + if (WACOM_PAD_FIELD(field) && wacom->wacom_wac.pad_input) return wacom_wac_pad_report(hdev, report); - else if (WACOM_PEN_FIELD(field)) + else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input) return wacom_wac_pen_report(hdev, report); - else if (WACOM_FINGER_FIELD(field)) + else if (WACOM_FINGER_FIELD(field) && wacom->wacom_wac.touch_input) return wacom_wac_finger_report(hdev, report); }