Description
usbLinkOpen()
in the develop
branch calls libusb_ref_device()
to increment the ref, but I can not find any code that will decrement it using libusb_unref_device()
.
This is suspicious and may have unwanted sideaffects. libusb doc writes that ref/unref need to be matched and when ref=0 a device is finally destroyed.
libusb_ref_device()
only exists one place...it is within refLibusbDeviceByName()
XLink/src/pc/protocols/usb_host.cpp
Line 244 in 457b23f
That function above refLibusbDeviceByName()
is called by code in three locations...
usb_boot()
location
Looks correct to me. It has a matching unref
.
XLink/src/pc/protocols/usb_host.cpp
Lines 632 to 665 in 457b23f
usbLinkBootBootloader()
location
Looks correct to me. It has a matching unref
.
XLink/src/pc/protocols/usb_host.cpp
Line 714 in 457b23f
usbLinkOpen
location
Looks suspicious. It calls refLibusbDeviceByName
which increments the ref. But nothing calls unref
. If I guess, I would think there should be an unref in usbLinkClose
but there is not.
XLink/src/pc/protocols/usb_host.cpp
Line 687 in 457b23f