Commit d0f1d5ae authored by Evgeny Novikov's avatar Evgeny Novikov Committed by Jiri Kosina
Browse files

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: default avatarEvgeny Novikov <novikov@ispras.ru>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent df04fbe8
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -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);