GCAdapter: Close libusb handle if an open error occurs

The handle was previously kept open, which was causing future adapter
plug/unplug events to be ignored.
This commit is contained in:
Vincent Duvert 2018-07-17 22:29:48 +02:00
parent 80d8173d29
commit 0165e5e703
1 changed files with 6 additions and 0 deletions

View File

@ -276,12 +276,18 @@ static bool CheckDeviceAccess(libusb_device* device)
// this split is needed so that we don't avoid claiming the interface when
// detaching the kernel driver is successful
if (ret != 0 && ret != LIBUSB_ERROR_NOT_SUPPORTED)
{
libusb_close(s_handle);
s_handle = nullptr;
return false;
}
ret = libusb_claim_interface(s_handle, 0);
if (ret)
{
ERROR_LOG(SERIALINTERFACE, "libusb_claim_interface failed with error: %d", ret);
libusb_close(s_handle);
s_handle = nullptr;
return false;
}