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: 665723 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 368FDC6FD1D for ; Mon, 20 Mar 2023 15:44:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232248AbjCTPoP (ORCPT ); Mon, 20 Mar 2023 11:44:15 -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) Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org 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;