core: only increment devices_released when a device is destroyed
authorNathan Hjelm <hjelmn@google.com>
Fri, 11 Jun 2021 03:02:05 +0000 (21:02 -0600)
committerNathan Hjelm <hjelmn@google.com>
Fri, 11 Jun 2021 03:02:05 +0000 (21:02 -0600)
Fix a typo in the last commit to ensure the loop does exit when there is
a dangling reference.

Signed-off-by: Nathan Hjelm <hjelmn@google.com>
libusb/hotplug.c
libusb/version_nano.h

index deb138d..b6f896a 100644 (file)
@@ -198,10 +198,11 @@ void usbi_hotplug_exit(struct libusb_context *ctx)
                        /* remove the device from the usb_devs list only if there are no
                         * references held, otherwise leave it on the list so that a
                         * warning message will be shown */
-                       if (usbi_atomic_load(&dev->refcnt) == 1)
+                       if (usbi_atomic_load(&dev->refcnt) == 1) {
+                               ++devices_released;
                                list_del(&dev->list);
+                       }
                        libusb_unref_device(dev);
-                       ++devices_released;
                }
        } while (devices_released > 0);
 
index 21591b9..3924959 100644 (file)
@@ -1 +1 @@
-#define LIBUSB_NANO 11624
+#define LIBUSB_NANO 11625