From patchwork Mon Mar 20 15:34:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikita Zhandarovich X-Patchwork-Id: 72228 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp1291479wrt; Mon, 20 Mar 2023 08:53:11 -0700 (PDT) X-Google-Smtp-Source: AK7set+j1fnVCicFrmeIlZcLm2KyQLNGW942PMyYeRrF5APxL6SA07NChwJOejV9jJxwfLOVsBRT X-Received: by 2002:a05:6a20:3b2f:b0:d7:d894:66c2 with SMTP id c47-20020a056a203b2f00b000d7d89466c2mr10948989pzh.62.1679327591542; Mon, 20 Mar 2023 08:53:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679327591; cv=none; d=google.com; s=arc-20160816; b=MkXcn9jiPSLaVL+5DKw7EItbBeH47eauyQ10adiXwZ6BCxWtqrjkuGTacX9T+v1X2Z C0Xa6qM6LR9h5iV5x0lLAHNNAJVfJEn5cA1oSo+dgfILgRpelMs1sx/t4lnvQQVMh00A JZd/ft1DxnUXitJHiCunMYXdDMPgtVNmwhC5w5d/7KmmWsQMiA7Dwfgt3XnZAG6RGMq3 USgvnnYKBiIFcI0AbOJavqdBU4qgHAGFlXQJQiQO2l8TA3IBgzSCVsHT4E5sueeUl+Z6 5/p6vdGbdEjbZ5kwQ7psm/0UnGfEEeTG1SPboAcZXSgPv+jEUOUyUm/yRHNqtyvPxm3o mmaQ== 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=h5K2Aahi9X2pIwWXbAMzpRUYvyVcmydrlezG+4dpwtc=; b=LCcTJ5+r59pRA9mw+4MXekRmRtgzz7J7O2tyPNEH/G2rDLtUB4xweJxUk3vJvGOmIh lnLAvlnpd7adBxmtX/S92WasvF4g6L8bnfQRfAkry+vmrsVQKqb7Cbu+YmccsDY/V1lo gJTopNv11RXqCPQoY6nSS85UwQY2m+nBo7aVlZRAWSTIuFpOX28XHqVJGw5UIEybR/47 c+ajFQ/UIzTz8V5ZOZtS70uz8X/Y2LI0QpeWRa+RhL7Nsq78WUg68mGzyzdEMV5WNHoa SUIWqzqQaAbtGFI5f4i8sshQWM5dG/82JdoGu2wREfjL1sdQ6Dd2pcbG8UfxBC9Izr1Z CyPQ== 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 j15-20020a63cf0f000000b004fb8f5e1a8dsi10261562pgg.111.2023.03.20.08.52.58; Mon, 20 Mar 2023 08:53:11 -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 S231659AbjCTPoR (ORCPT + 99 others); Mon, 20 Mar 2023 11:44:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231396AbjCTPnq (ORCPT ); Mon, 20 Mar 2023 11:43:46 -0400 Received: from exchange.fintech.ru (exchange.fintech.ru [195.54.195.159]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A3DF3D92C; Mon, 20 Mar 2023 08:34:36 -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; Mon, 20 Mar 2023 18:34:24 +0300 Received: from localhost (10.0.253.157) 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; Mon, 20 Mar 2023 18:34:24 +0300 From: Nikita Zhandarovich To: David Rheinsberg CC: Nikita Zhandarovich , Jiri Kosina , Benjamin Tissoires , "David Herrmann" , , , Subject: [PATCH] HID: wiimote: check completion in wiimod_battery_get_property Date: Mon, 20 Mar 2023 08:34:19 -0700 Message-ID: <20230320153419.9185-1-n.zhandarovich@fintech.ru> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Originating-IP: [10.0.253.157] 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 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760902608807140971?= X-GMAIL-MSGID: =?utf-8?q?1760902608807140971?= wiimote_cmd_wait() in wiimod_battery_get_property() may signal that the task of getting specific battery property was interrupted or timed out. There is no need to do any further computation in such cases, so just return the error. Found by Linux Verification Center (linuxtesting.org) with static analysis tool SVACE. Fixes: dcf392313817 ("HID: wiimote: convert BATTERY to module") Signed-off-by: Nikita Zhandarovich --- drivers/hid/hid-wiimote-modules.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/hid/hid-wiimote-modules.c b/drivers/hid/hid-wiimote-modules.c index dbccdfa63916..9755718d9856 100644 --- a/drivers/hid/hid-wiimote-modules.c +++ b/drivers/hid/hid-wiimote-modules.c @@ -220,8 +220,10 @@ static int wiimod_battery_get_property(struct power_supply *psy, wiiproto_req_status(wdata); spin_unlock_irqrestore(&wdata->state.lock, flags); - wiimote_cmd_wait(wdata); + ret = wiimote_cmd_wait(wdata); wiimote_cmd_release(wdata); + if (ret) + return ret; spin_lock_irqsave(&wdata->state.lock, flags); state = wdata->state.cmd_battery;