mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jeongjun Park <aha310510@gmail.com>
To: jikos@kernel.org, bentiss@kernel.org
Cc: andrew.smirnov@gmail.com, juha.kuikka@gmail.com,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	Jeongjun Park <aha310510@gmail.com>
Subject: [PATCH] HID: microsoft: add a call hid_hw_stop() in probe()
Date: Thu, 17 Jul 2025 02:22:21 +0900	[thread overview]
Message-ID: <20250716172221.1360886-1-aha310510@gmail.com> (raw)

If hid_hw_start() succeeds but ms_init_ff() fails, it will return without
calling hid_hw_stop(), which will cause a memory leak. So to prevent this,
we need to change probe() to call hid_hw_stop().

Fixes: 73c5b254c365 ("HID: microsoft: Add rumble support for Xbox One S controller")
Signed-off-by: Jeongjun Park <aha310510@gmail.com>
---
 drivers/hid/hid-microsoft.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/hid/hid-microsoft.c b/drivers/hid/hid-microsoft.c
index 18ac21c0bcb2..a27ea59a1bef 100644
--- a/drivers/hid/hid-microsoft.c
+++ b/drivers/hid/hid-microsoft.c
@@ -385,22 +385,26 @@ static int ms_probe(struct hid_device *hdev, const struct hid_device_id *id)
 	ret = hid_parse(hdev);
 	if (ret) {
 		hid_err(hdev, "parse failed\n");
-		goto err_free;
+		return ret;
 	}
 
 	ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT | ((quirks & MS_HIDINPUT) ?
 				HID_CONNECT_HIDINPUT_FORCE : 0));
 	if (ret) {
 		hid_err(hdev, "hw start failed\n");
-		goto err_free;
+		return ret;
 	}
 
 	ret = ms_init_ff(hdev);
-	if (ret)
+	if (ret) {
 		hid_err(hdev, "could not initialize ff, continuing anyway");
+		goto err_hw_stop;
+	}
 
 	return 0;
-err_free:
+
+err_hw_stop:
+	hid_hw_stop(hdev);
 	return ret;
 }
 
--

             reply	other threads:[~2025-07-16 17:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-16 17:22 Jeongjun Park [this message]
2025-07-16 21:08 ` Andrey Smirnov
2025-07-17  2:58   ` Jeongjun Park

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=20250716172221.1360886-1-aha310510@gmail.com \
    --to=aha310510@gmail.com \
    --cc=andrew.smirnov@gmail.com \
    --cc=bentiss@kernel.org \
    --cc=jikos@kernel.org \
    --cc=juha.kuikka@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.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

all inboxes | Powered by JetHome®