libusb_get_configuration() can still fail after the device has been
opened, so check its actual return value before trusting the returned
current_configuration.
*/
current_configuration = -1;
*/
current_configuration = -1;
- libusb_get_configuration((*dev)->usb_device, ¤t_configuration);
+ ret = libusb_get_configuration((*dev)->usb_device,
+ ¤t_configuration);
+ if (ret < 0) {
+ debug(ctx, "libusb_get_configuration failed: %s\n",
+ libusb_error_name(ret));
+ goto out_libusb_close;
+ }
+
if (current_configuration != (*dev)->desc->configuration) {
/*
* In principle kernel drivers bound to each interface should
if (current_configuration != (*dev)->desc->configuration) {
/*
* In principle kernel drivers bound to each interface should
* http://libusb.sourceforge.net/api-1.0/caveats.html
*/
current_configuration = -1;
* http://libusb.sourceforge.net/api-1.0/caveats.html
*/
current_configuration = -1;
- libusb_get_configuration((*dev)->usb_device, ¤t_configuration);
+ ret = libusb_get_configuration((*dev)->usb_device,
+ ¤t_configuration);
+ if (ret < 0) {
+ debug(ctx, "libusb_get_configuration after claim failed: %s\n",
+ libusb_error_name(ret));
+ goto out_libusb_close;
+ }
+
if (current_configuration != (*dev)->desc->configuration) {
debug(ctx, "libusb configuration changed (expected: %hhu, current: %hhu\n",
(*dev)->desc->configuration, current_configuration);
if (current_configuration != (*dev)->desc->configuration) {
debug(ctx, "libusb configuration changed (expected: %hhu, current: %hhu\n",
(*dev)->desc->configuration, current_configuration);