[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210730165110.24667-1-novikov@ispras.ru>
Date: Fri, 30 Jul 2021 19:51:08 +0300
From: Evgeny Novikov <novikov@...ras.ru>
To: Jiri Kosina <jikos@...nel.org>
Cc: Evgeny Novikov <novikov@...ras.ru>,
Benjamin Tissoires <benjamin.tissoires@...hat.com>,
Maxime Coquelin <mcoquelin.stm32@...il.com>,
Alexandre Torgue <alexandre.torgue@...s.st.com>,
linux-input@...r.kernel.org,
linux-stm32@...md-mailman.stormreply.com,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
ldv-project@...uxtesting.org
Subject: [PATCH 1/3] HID: thrustmaster: Fix memory leaks in probe
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@...ras.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
Powered by blists - more mailing lists