Commit 501a5250 authored by Dmitry Torokhov's avatar Dmitry Torokhov

Input: gtco - fix double kfree in error handling path

The code would try to free 'report' twice upon input_register_device()
failure.
Reported-by: default avatarJulia Lawall <julia@diku.dk>
Signed-off-by: default avatarDmitry Torokhov <dtor@mail.ru>
parent 471637a5
...@@ -830,7 +830,7 @@ static int gtco_probe(struct usb_interface *usbinterface, ...@@ -830,7 +830,7 @@ static int gtco_probe(struct usb_interface *usbinterface,
struct gtco *gtco; struct gtco *gtco;
struct input_dev *input_dev; struct input_dev *input_dev;
struct hid_descriptor *hid_desc; struct hid_descriptor *hid_desc;
char *report = NULL; char *report;
int result = 0, retry; int result = 0, retry;
int error; int error;
struct usb_endpoint_descriptor *endpoint; struct usb_endpoint_descriptor *endpoint;
...@@ -916,12 +916,16 @@ static int gtco_probe(struct usb_interface *usbinterface, ...@@ -916,12 +916,16 @@ static int gtco_probe(struct usb_interface *usbinterface,
le16_to_cpu(hid_desc->wDescriptorLength), le16_to_cpu(hid_desc->wDescriptorLength),
5000); /* 5 secs */ 5000); /* 5 secs */
if (result == le16_to_cpu(hid_desc->wDescriptorLength)) dbg("usb_control_msg result: %d", result);
if (result == le16_to_cpu(hid_desc->wDescriptorLength)) {
parse_hid_report_descriptor(gtco, report, result);
break; break;
}
} }
kfree(report);
/* If we didn't get the report, fail */ /* If we didn't get the report, fail */
dbg("usb_control_msg result: :%d", result);
if (result != le16_to_cpu(hid_desc->wDescriptorLength)) { if (result != le16_to_cpu(hid_desc->wDescriptorLength)) {
err("Failed to get HID Report Descriptor of size: %d", err("Failed to get HID Report Descriptor of size: %d",
hid_desc->wDescriptorLength); hid_desc->wDescriptorLength);
...@@ -929,12 +933,6 @@ static int gtco_probe(struct usb_interface *usbinterface, ...@@ -929,12 +933,6 @@ static int gtco_probe(struct usb_interface *usbinterface,
goto err_free_urb; goto err_free_urb;
} }
/* Now we parse the report */
parse_hid_report_descriptor(gtco, report, result);
/* Now we delete it */
kfree(report);
/* Create a device file node */ /* Create a device file node */
usb_make_path(gtco->usbdev, gtco->usbpath, sizeof(gtco->usbpath)); usb_make_path(gtco->usbdev, gtco->usbpath, sizeof(gtco->usbpath));
strlcat(gtco->usbpath, "/input0", sizeof(gtco->usbpath)); strlcat(gtco->usbpath, "/input0", sizeof(gtco->usbpath));
...@@ -988,7 +986,6 @@ static int gtco_probe(struct usb_interface *usbinterface, ...@@ -988,7 +986,6 @@ static int gtco_probe(struct usb_interface *usbinterface,
usb_buffer_free(gtco->usbdev, REPORT_MAX_SIZE, usb_buffer_free(gtco->usbdev, REPORT_MAX_SIZE,
gtco->buffer, gtco->buf_dma); gtco->buffer, gtco->buf_dma);
err_free_devs: err_free_devs:
kfree(report);
input_free_device(input_dev); input_free_device(input_dev);
kfree(gtco); kfree(gtco);
return error; return error;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment