python748 / btstack

Automatically exported from code.google.com/p/btstack
0 stars 0 forks source link

Data sources and memory leaks in hci_transport_usv #397

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I've noticed two leaks in hci_transport_usb:
- The first one is pretty minor: After calling libusb_get_pollfds in usb_open, 
the pollfd array isn't freed (should be freed with after creating the data 
sources).
- The seconds one is a bit more important: The data usb data sources added to 
the run loop are never removed or freed when calling usb_close. Besides the 
obvious memory leak of the data_source_t structs, the file descriptors 
shouldn't be used after the device (and libusb) was closed.

So i think that usb_open should store the data sources it creates, and 
usb_close should remove them from the run loop and free them. The only problem 
I see is that its a problem to add the data sources to a linked list, since 
they are added to the run loop's internal linked list.

Original issue reported on code.google.com by kob...@mce-sys.com on 12 Jun 2014 at 1:09

GoogleCodeExporter commented 8 years ago
HI. Thanks once more. I've decided to put the data source into an array which 
makes freeing them later easy. Please have a look if it work (r2612) s. As far 
as I know, the pollfd thing only works in linux in theory, and it didin't work 
with this driver, so I have (temp) disabled it's use until someone debugs/needs 
it on linux.

Original comment by matthias.ringwald@gmail.com on 12 Jun 2014 at 3:27