From patchwork Thu Dec 8 00:18:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ping Cheng X-Patchwork-Id: 9465479 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 5929E60512 for ; Thu, 8 Dec 2016 00:18:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6613028533 for ; Thu, 8 Dec 2016 00:18:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 59DC3285A3; Thu, 8 Dec 2016 00:18:27 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, 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 CDA2628533 for ; Thu, 8 Dec 2016 00:18:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933724AbcLHASZ (ORCPT ); Wed, 7 Dec 2016 19:18:25 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:33605 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933614AbcLHASZ (ORCPT ); Wed, 7 Dec 2016 19:18:25 -0500 Received: by mail-pg0-f68.google.com with SMTP id 3so24957779pgd.0 for ; Wed, 07 Dec 2016 16:18:25 -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=gjAxP8145WSE+zyc07RnOOL2Td+0kvdlovN0ay6sdVQ=; b=NWFsgmJ6VAr909ByeEStRQVyoAibg1/7nkW+GEFEfhixSvG/w57/TidSI5xO7h1yg/ NV7iLbDygnWmv2dEdnN18mprbISFcMAPJBlkaWsNAz28U0xtVt4rFPbrSks0SDZMtMxi c1XbN1kWoH+W385GZ4OZUeWKAUmPh/LyPno5TWsyrHlvapSGvidDBwLCgkFrJn+kQKGm XtOP0PidilritWoLClK5g/oKsfF3cXnWv1E/NaB27BePY43nMAL1NwMMeNwKyjr8Div7 yALfpgYU33CxjEJtiz2A00fPfE6mySQMaZXsDrceheTO5MR09K8kq7jfzJtuEtNcYaTV p3ZQ== 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=gjAxP8145WSE+zyc07RnOOL2Td+0kvdlovN0ay6sdVQ=; b=XCgKTyZuXVNhmGfIqWAXhu04wN9gm7PE+rImWT1gmQW0VpTvDh+yoZv5xVja/ivagu WUExz+8703+Mh1MtN8fdcYbaSrfL3TE8spnfiD9YUc3Leek1reZ4XdPYAFflMBv43KPl exbYtdTzB6o9oDQXqPJK7rAbCz0Pa3+VZKDcEuNI1wafg487cQLp8QPo+BLt9oZway8q EQ5oVUnZjixWPSEh9R4mUr+9F61sHjesg8Lwkmus11JBZa3028t6DeYpjzhTn/6ooa81 Tp5K6qfakEyA6zxHrkA79SCXTsa0EgeXrWM9L4dwX2/19VGsnDHdHM7qQGzXAHxQ7YoP GuZg== X-Gm-Message-State: AKaTC03lEjZthmvAi0MYoB5LR+EplCsmFNJX23Rj98a4SL3WlUm2iuu6IXfHNeMCnpd2DA== X-Received: by 10.99.170.79 with SMTP id x15mr125677759pgo.14.1481156304697; Wed, 07 Dec 2016 16:18:24 -0800 (PST) Received: from wacom-XPS-8500.corp.onewacom.com ([50.225.60.4]) by smtp.gmail.com with ESMTPSA id f14sm45244615pfk.5.2016.12.07.16.18.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 07 Dec 2016 16:18:24 -0800 (PST) From: Ping Cheng X-Google-Original-From: Ping Cheng To: linux-input@vger.kernel.org Cc: jkosina@suse.cz, benjamin.tissoires@redhat.com, Ping Cheng , Ping Cheng Subject: [PATCH 2/4] HID: wacom: generic: Send data only when the interface is defined Date: Wed, 7 Dec 2016 16:18:10 -0800 Message-Id: <1481156290-5309-1-git-send-email-pingc@wacom.com> X-Mailer: git-send-email 2.7.4 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 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 --- 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); }