From d0f1d5ae23803bd82647a337fa508fa8615defc5 Mon Sep 17 00:00:00 2001 From: Evgeny Novikov Date: Fri, 30 Jul 2021 19:51:08 +0300 Subject: 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 Signed-off-by: Jiri Kosina --- 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); -- cgit v1.2.3 From df3a97bdbc252d3421f1c5d6d713ad6e4f36a469 Mon Sep 17 00:00:00 2001 From: Evgeny Novikov Date: Fri, 30 Jul 2021 19:51:09 +0300 Subject: HID: thrustmaster: Fix memory leak in remove 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 Signed-off-by: Jiri Kosina --- 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); -- cgit v1.2.3 From c3800eed22d21c66912b4461a403b4448ed88d95 Mon Sep 17 00:00:00 2001 From: Evgeny Novikov Date: Fri, 30 Jul 2021 19:53:33 +0300 Subject: HID: thrustmaster: Fix memory leak in thrustmaster_interrupts() thrustmaster_interrupts() does not free memory for send_buf when usb_interrupt_msg() fails. This is fixed by the given patch. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Evgeny Novikov Signed-off-by: Jiri Kosina --- 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 9cb4248f95af..d44550aa8805 100644 --- a/drivers/hid/hid-thrustmaster.c +++ b/drivers/hid/hid-thrustmaster.c @@ -173,6 +173,7 @@ static void thrustmaster_interrupts(struct hid_device *hdev) if (ret) { hid_err(hdev, "setup data couldn't be sent\n"); + kfree(send_buf); return; } } -- cgit v1.2.3