Fix potential crash when libusb_detach_kernel_driver fails #363

Merged
Youw merged 1 commit from fix-crash into master 2022-01-03 06:16:37 -06:00
Youw commented 2021-12-30 10:25:31 -06:00 (Migrated from github.com)

In case if libusb_detach_kernel_driver fails inside hidapi_initialize_device
HIDAPI had tried to libusb_close(dev->device_handle) two times:

  • right after libusb_detach_kernel_driver;
  • outside of hidapi_initialize_device function;

The fix: libusb_close the device only once.
And since hidapi_initialize_device is not responsible for opening the device -
it is not responsible for closing it either.

In case if libusb_detach_kernel_driver fails inside hidapi_initialize_device HIDAPI had tried to `libusb_close(dev->device_handle)` two times: - right after `libusb_detach_kernel_driver`; - outside of `hidapi_initialize_device` function; The fix: `libusb_close` the device only once. And since `hidapi_initialize_device` is not responsible for opening the device - it is not responsible for closing it either.
Sign in to join this conversation.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-libusb/hidapi!363
No description provided.