Only libusb close if libusb release succeeds.
diff --git a/usbutils.c b/usbutils.c
index 323bd7c..aad0a40 100644
--- a/usbutils.c
+++ b/usbutils.c
@@ -1328,8 +1328,8 @@ void usb_uninit(struct cgpu_info *cgpu)
// if release_cgpu() was called due to a USB NODEV(err)
if (!cgpu->usbdev)
return;
- libusb_release_interface(cgpu->usbdev->handle, cgpu->usbdev->found->interface);
- libusb_close(cgpu->usbdev->handle);
+ if (!libusb_release_interface(cgpu->usbdev->handle, cgpu->usbdev->found->interface))
+ libusb_close(cgpu->usbdev->handle);
cgpu->usbdev = free_cgusb(cgpu->usbdev);
}