linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nikita Zhandarovich <n.zhandarovich@fintech.ru>
To: David Rheinsberg <david.rheinsberg@gmail.com>
Cc: Nikita Zhandarovich <n.zhandarovich@fintech.ru>,
	Jiri Kosina <jikos@kernel.org>,
	Benjamin Tissoires <benjamin.tissoires@redhat.com>,
	"David Herrmann" <dh.herrmann@gmail.com>,
	<linux-input@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<lvc-project@linuxtesting.org>
Subject: [PATCH] HID: wiimote: check completion in wiimod_battery_get_property
Date: Mon, 20 Mar 2023 08:34:19 -0700	[thread overview]
Message-ID: <20230320153419.9185-1-n.zhandarovich@fintech.ru> (raw)

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 <n.zhandarovich@fintech.ru>
---
 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;
-- 
2.25.1


             reply	other threads:[~2023-03-20 15:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-20 15:34 Nikita Zhandarovich [this message]
2023-03-20 19:08 ` [PATCH] HID: wiimote: check completion in wiimod_battery_get_property David Rheinsberg
2023-03-21  6:13   ` Nikita Zhandarovich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230320153419.9185-1-n.zhandarovich@fintech.ru \
    --to=n.zhandarovich@fintech.ru \
    --cc=benjamin.tissoires@redhat.com \
    --cc=david.rheinsberg@gmail.com \
    --cc=dh.herrmann@gmail.com \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lvc-project@linuxtesting.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).