LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 1/3] HID: thrustmaster: Fix memory leaks in probe
@ 2021-07-30 16:51 Evgeny Novikov
  2021-07-30 16:51 ` [PATCH 2/3] HID: thrustmaster: Fix memory leak in remove Evgeny Novikov
  2021-08-20 12:25 ` [PATCH 1/3] HID: thrustmaster: Fix memory leaks in probe Jiri Kosina
  0 siblings, 2 replies; 3+ messages in thread
From: Evgeny Novikov @ 2021-07-30 16:51 UTC (permalink / raw)
  To: Jiri Kosina
  Cc: Evgeny Novikov, Benjamin Tissoires, Maxime Coquelin,
	Alexandre Torgue, linux-input, linux-stm32, linux-arm-kernel,
	linux-kernel, ldv-project

When thrustmaster_probe() handles errors of usb_submit_urb() it does not
free allocated resources and fails. The patch fixes that.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Evgeny Novikov <novikov@ispras.ru>
---
 drivers/hid/hid-thrustmaster.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/hid/hid-thrustmaster.c b/drivers/hid/hid-thrustmaster.c
index cdc7d82ae9ed..e94d3409fd10 100644
--- a/drivers/hid/hid-thrustmaster.c
+++ b/drivers/hid/hid-thrustmaster.c
@@ -336,11 +336,14 @@ static int thrustmaster_probe(struct hid_device *hdev, const struct hid_device_i
 	);
 
 	ret = usb_submit_urb(tm_wheel->urb, GFP_ATOMIC);
-	if (ret)
+	if (ret) {
 		hid_err(hdev, "Error %d while submitting the URB. I am unable to initialize this wheel...\n", ret);
+		goto error6;
+	}
 
 	return ret;
 
+error6: kfree(tm_wheel->change_request);
 error5: kfree(tm_wheel->response);
 error4: kfree(tm_wheel->model_request);
 error3: usb_free_urb(tm_wheel->urb);
-- 
2.26.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/3] HID: thrustmaster: Fix memory leak in remove
  2021-07-30 16:51 [PATCH 1/3] HID: thrustmaster: Fix memory leaks in probe Evgeny Novikov
@ 2021-07-30 16:51 ` Evgeny Novikov
  2021-08-20 12:25 ` [PATCH 1/3] HID: thrustmaster: Fix memory leaks in probe Jiri Kosina
  1 sibling, 0 replies; 3+ messages in thread
From: Evgeny Novikov @ 2021-07-30 16:51 UTC (permalink / raw)
  To: Jiri Kosina
  Cc: Evgeny Novikov, Benjamin Tissoires, Maxime Coquelin,
	Alexandre Torgue, linux-input, linux-stm32, linux-arm-kernel,
	linux-kernel, ldv-project

thrustmaster_remove() does not release memory for
tm_wheel->change_request. This is fixed by the patch.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Evgeny Novikov <novikov@ispras.ru>
---
 drivers/hid/hid-thrustmaster.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/hid/hid-thrustmaster.c b/drivers/hid/hid-thrustmaster.c
index e94d3409fd10..9cb4248f95af 100644
--- a/drivers/hid/hid-thrustmaster.c
+++ b/drivers/hid/hid-thrustmaster.c
@@ -253,6 +253,7 @@ static void thrustmaster_remove(struct hid_device *hdev)
 
 	usb_kill_urb(tm_wheel->urb);
 
+	kfree(tm_wheel->change_request);
 	kfree(tm_wheel->response);
 	kfree(tm_wheel->model_request);
 	usb_free_urb(tm_wheel->urb);
-- 
2.26.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/3] HID: thrustmaster: Fix memory leaks in probe
  2021-07-30 16:51 [PATCH 1/3] HID: thrustmaster: Fix memory leaks in probe Evgeny Novikov
  2021-07-30 16:51 ` [PATCH 2/3] HID: thrustmaster: Fix memory leak in remove Evgeny Novikov
@ 2021-08-20 12:25 ` Jiri Kosina
  1 sibling, 0 replies; 3+ messages in thread
From: Jiri Kosina @ 2021-08-20 12:25 UTC (permalink / raw)
  To: Evgeny Novikov
  Cc: Benjamin Tissoires, Maxime Coquelin, Alexandre Torgue,
	linux-input, linux-stm32, linux-arm-kernel, linux-kernel,
	ldv-project

On Fri, 30 Jul 2021, Evgeny Novikov wrote:

> When thrustmaster_probe() handles errors of usb_submit_urb() it does not
> free allocated resources and fails. The patch fixes that.
> 
> Found by Linux Driver Verification project (linuxtesting.org).
> 
> Signed-off-by: Evgeny Novikov <novikov@ispras.ru>

I've applied all three fixes, thanks.

-- 
Jiri Kosina
SUSE Labs


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-08-20 12:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-30 16:51 [PATCH 1/3] HID: thrustmaster: Fix memory leaks in probe Evgeny Novikov
2021-07-30 16:51 ` [PATCH 2/3] HID: thrustmaster: Fix memory leak in remove Evgeny Novikov
2021-08-20 12:25 ` [PATCH 1/3] HID: thrustmaster: Fix memory leaks in probe Jiri Kosina

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).