Skip to content

Commit

Permalink
usb: Attempt detaching kernel driver
Browse files Browse the repository at this point in the history
In the event that the kernel have some other driver attached to the
device the attempt claim of the interface will fail.

Lost in the libusb conversion was a call to USBDEVFS_DISCONNECT to first
detach any such drivers. Reintroduce this by invoking
libusb_detach_kernel_driver().

As with some other libusb functions there are multiple return values
denoting "success", so rely on libusb_claim_interface() to catch the
actual errors.

Reported-by: Maxim Akristiniy
Suggested-by: Maxim Akristiniy
Signed-off-by: Bjorn Andersson <[email protected]>
  • Loading branch information
quic-bjorande authored and Konrad Dybcio committed Jun 7, 2024
1 parent 8b01b62 commit 1d8a3ff
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ static int qdl_try_open(libusb_device *dev, struct qdl_device *qdl, const char *
continue;
}

libusb_detach_kernel_driver(handle, ifc->bInterfaceNumber);

ret = libusb_claim_interface(handle, ifc->bInterfaceNumber);
if (ret < 0) {
warnx("failed to claim USB interface");
Expand Down

0 comments on commit 1d8a3ff

Please sign in to comment.