Message ID | 20230613101635.77820-1-n.zhandarovich@fintech.ru |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp435393vqr; Tue, 13 Jun 2023 03:21:20 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ486yJB3Sa97KEZ8v5VX9I4Lj5JF2mrfs0MO7AxEYFGMNyhIZB2fOvDHQ0LpJXjaWxUgqTy X-Received: by 2002:a17:907:3681:b0:971:eb29:a082 with SMTP id bi1-20020a170907368100b00971eb29a082mr11806390ejc.49.1686651679969; Tue, 13 Jun 2023 03:21:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686651679; cv=none; d=google.com; s=arc-20160816; b=bkNd2lWmlicFSmXQ4+wSYNFyXYEVHfZRxEHwjRjXhUCDw1J9fkRLaTuWGv4lg3Uirn gmEVN/FpQj3az/XI5CLKrY/SEiYuoa/j+W/M9PhWg5Jv4zEjlqZvFWTQc4ElU81Hd5QA UIcH5rCzZA4gx8Sr7wxQutFhyBvZwWx+SNE0SGuIwWMh1EXUNNn0ZOb6EXUAox4YTTU9 NlwXMG8x7kG1smCHZ6StiY1n+Zrb4ri+m1B0VRWVNq4zW3uYamD1r9a7p+wU9+mWOH0F MIjtfKBNw2HtQQLKOCz+cJQyGWL9MY2dwfRCYF6Zx6pJMGqEjccM+8WrSICtizpPRS8Y B4gQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=fwV/MGSublybBqRik4WFoD26/2HUpE6aVMYh0LbwZ4c=; b=b3XaK/KiR9FqjgVFnLrUI5bQEId2DnYrylQrIHTLfzHhueAd5tgtH8JLkK7v5nA0AU hfM0EPPLb4jM5WhIT2E8HXOvJ6CYbT7DKKHh/R4/RoINySKFJ72+1z2cTy/HDzpY7sP/ jM8l9On8+P9VfrzU7Uk+UTwR4u2Ks2Dds+CUZNf+hT7AYwT1G6Q9BS5Fnr4WyN6m/2HS OvhNMB8CZyEubk1SlQTIXDL4KMP+styVTfbjKzF9pZc3VHmiL0T34S1EJtPimsg1tawD /2MSvsN7HFQnK+CUJIZUovaAFuTAMBPvIv/xb380rfr7zOF3QgLIRlj7Cdus+Rzpzqiz X+LQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kj8-20020a170907764800b00977c8ca1c6asi3605551ejc.729.2023.06.13.03.20.54; Tue, 13 Jun 2023 03:21:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239026AbjFMKRL (ORCPT <rfc822;rust.linux@gmail.com> + 99 others); Tue, 13 Jun 2023 06:17:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235790AbjFMKRJ (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 13 Jun 2023 06:17:09 -0400 Received: from exchange.fintech.ru (e10edge.fintech.ru [195.54.195.159]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6523313A; Tue, 13 Jun 2023 03:17:03 -0700 (PDT) Received: from Ex16-01.fintech.ru (10.0.10.18) by exchange.fintech.ru (195.54.195.169) with Microsoft SMTP Server (TLS) id 14.3.498.0; Tue, 13 Jun 2023 13:16:47 +0300 Received: from localhost (10.0.253.138) by Ex16-01.fintech.ru (10.0.10.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Tue, 13 Jun 2023 13:16:47 +0300 From: Nikita Zhandarovich <n.zhandarovich@fintech.ru> To: =?utf-8?q?Filipe_La=C3=ADns?= <lains@riseup.net> CC: Nikita Zhandarovich <n.zhandarovich@fintech.ru>, Jiri Kosina <jikos@kernel.org>, Benjamin Tissoires <benjamin.tissoires@redhat.com>, <linux-input@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <lvc-project@linuxtesting.org> Subject: [PATCH] HID: logitech-dj: Fix error handling in logi_dj_recv_switch_to_dj_mode() Date: Tue, 13 Jun 2023 03:16:35 -0700 Message-ID: <20230613101635.77820-1-n.zhandarovich@fintech.ru> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.0.253.138] X-ClientProxiedBy: Ex16-02.fintech.ru (10.0.10.19) To Ex16-01.fintech.ru (10.0.10.18) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768582471756558176?= X-GMAIL-MSGID: =?utf-8?q?1768582471756558176?= |
Series |
HID: logitech-dj: Fix error handling in logi_dj_recv_switch_to_dj_mode()
|
|
Commit Message
Nikita Zhandarovich
June 13, 2023, 10:16 a.m. UTC
Presently, if a call to logi_dj_recv_send_report() fails, we do
not learn about the error until after sending short
HID_OUTPUT_REPORT with hid_hw_raw_request().
To handle this somewhat unlikely issue, return on error in
logi_dj_recv_send_report() (minding ugly sleep workaround) and
take into account the result of hid_hw_raw_request().
Found by Linux Verification Center (linuxtesting.org) with static
analysis tool SVACE.
Fixes: 6a9ddc897883 ("HID: logitech-dj: enable notifications on connect/disconnect")
Signed-off-by: Nikita Zhandarovich <n.zhandarovich@fintech.ru>
---
drivers/hid/hid-logitech-dj.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
Comments
On Tue, 13 Jun 2023, Nikita Zhandarovich wrote: > Presently, if a call to logi_dj_recv_send_report() fails, we do > not learn about the error until after sending short > HID_OUTPUT_REPORT with hid_hw_raw_request(). > To handle this somewhat unlikely issue, return on error in > logi_dj_recv_send_report() (minding ugly sleep workaround) and > take into account the result of hid_hw_raw_request(). > > Found by Linux Verification Center (linuxtesting.org) with static > analysis tool SVACE. > > Fixes: 6a9ddc897883 ("HID: logitech-dj: enable notifications on connect/disconnect") > Signed-off-by: Nikita Zhandarovich <n.zhandarovich@fintech.ru> > --- > drivers/hid/hid-logitech-dj.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/drivers/hid/hid-logitech-dj.c b/drivers/hid/hid-logitech-dj.c > index 62180414efcc..e6a8b6d8eab7 100644 > --- a/drivers/hid/hid-logitech-dj.c > +++ b/drivers/hid/hid-logitech-dj.c > @@ -1285,6 +1285,9 @@ static int logi_dj_recv_switch_to_dj_mode(struct dj_receiver_dev *djrcv_dev, > * 50 msec should gives enough time to the receiver to be ready. > */ > msleep(50); > + > + if (retval) > + return retval; > } > > /* > @@ -1306,7 +1309,7 @@ static int logi_dj_recv_switch_to_dj_mode(struct dj_receiver_dev *djrcv_dev, > buf[5] = 0x09; > buf[6] = 0x00; > > - hid_hw_raw_request(hdev, REPORT_ID_HIDPP_SHORT, buf, > + retval = hid_hw_raw_request(hdev, REPORT_ID_HIDPP_SHORT, buf, > HIDPP_REPORT_SHORT_LENGTH, HID_OUTPUT_REPORT, > HID_REQ_SET_REPORT); Looks good to me. Benjamin, could you please Ack/apply it? Thanks,
On Tue, 13 Jun 2023 03:16:35 -0700, Nikita Zhandarovich wrote: > Presently, if a call to logi_dj_recv_send_report() fails, we do > not learn about the error until after sending short > HID_OUTPUT_REPORT with hid_hw_raw_request(). > To handle this somewhat unlikely issue, return on error in > logi_dj_recv_send_report() (minding ugly sleep workaround) and > take into account the result of hid_hw_raw_request(). > > [...] Applied to hid/hid.git (for-6.6/logitech), thanks! [1/1] HID: logitech-dj: Fix error handling in logi_dj_recv_switch_to_dj_mode() https://git.kernel.org/hid/hid/c/6f20d3261265 Cheers,
diff --git a/drivers/hid/hid-logitech-dj.c b/drivers/hid/hid-logitech-dj.c index 62180414efcc..e6a8b6d8eab7 100644 --- a/drivers/hid/hid-logitech-dj.c +++ b/drivers/hid/hid-logitech-dj.c @@ -1285,6 +1285,9 @@ static int logi_dj_recv_switch_to_dj_mode(struct dj_receiver_dev *djrcv_dev, * 50 msec should gives enough time to the receiver to be ready. */ msleep(50); + + if (retval) + return retval; } /* @@ -1306,7 +1309,7 @@ static int logi_dj_recv_switch_to_dj_mode(struct dj_receiver_dev *djrcv_dev, buf[5] = 0x09; buf[6] = 0x00; - hid_hw_raw_request(hdev, REPORT_ID_HIDPP_SHORT, buf, + retval = hid_hw_raw_request(hdev, REPORT_ID_HIDPP_SHORT, buf, HIDPP_REPORT_SHORT_LENGTH, HID_OUTPUT_REPORT, HID_REQ_SET_REPORT);