Export to GitHub

btstack - issue #397

Data sources and memory leaks in hci_transport_usv


Posted on Jun 12, 2014 by Swift Dog

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.

Comment #1

Posted on Jun 12, 2014 by Swift Ox

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.

Status: Fixed

Labels:
Type-Defect Priority-Medium